Commit bf928f02 authored by Raul Tambre's avatar Raul Tambre Committed by Commit Bot

mojo: Fix map() Python 3 compatibility

map() returns a list in Python 2. Python 3 returns an iterator.
Wrapping in a list() results in the same behaviour on both.

[1/2] ACTION //chrome/common:service_process_mojom__generator(//build/toolchain/win:win_clang_x64)
Traceback (most recent call last):
  File "../../mojo/public/tools/bindings/mojom_bindings_generator.py", line 556, in <module>
    sys.exit(main())
  File "../../mojo/public/tools/bindings/mojom_bindings_generator.py", line 551, in main
    return args.func(args, remaining_args)
  File "../../mojo/public/tools/bindings/mojom_bindings_generator.py", line 267, in _Generate
    processor._GenerateModule(args, remaining_args, generator_modules,
  File "../../mojo/public/tools/bindings/mojom_bindings_generator.py", line 238, in _GenerateModule
    generator.GenerateFiles(filtered_args)
  File "C:\Google\chromium\src\mojo\public\tools\bindings\generators\mojom_cpp_generator.py", line 478, in GenerateFiles
    self.WriteWithComment(self._GenerateModuleSource(),
  File "C:\Google\chromium\src\mojo\public\tools\bindings\pylib\mojom\generate\template_expander.py", line 37, in GeneratorInternal
    return ApplyTemplate(args[0], path_to_template, parameters, **kwargs)
  File "C:\Google\chromium\src\mojo\public\tools\bindings\pylib\mojom\generate\template_expander.py", line 30, in ApplyTemplate
    return template.render(params)
  File "C:\Google\chromium\src\mojo\public\tools\bindings\pylib\mojom\generate\..\..\..\..\..\..\..\third_party\jinja2\asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "C:\Google\chromium\src\mojo\public\tools\bindings\pylib\mojom\generate\..\..\..\..\..\..\..\third_party\jinja2\environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "C:\Google\chromium\src\mojo\public\tools\bindings\pylib\mojom\generate\..\..\..\..\..\..\..\third_party\jinja2\environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Google\chromium\src\mojo\public\tools\bindings\pylib\mojom\generate\..\..\..\..\..\..\..\third_party\jinja2\_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "gen\mojo\public\tools\bindings\cpp_templates.zip\tmpl_443233f41d2b3f893c5bf0eb0f069e01da908ebe.py", line 100, in <module>
  File "gen\mojo\public\tools\bindings\cpp_templates.zip\tmpl_71c6d092b6dca901ff3ed0d20e7c827a088fac2d.py", line 523, in <module>
  File "C:\Google\chromium\src\mojo\public\tools\bindings\generators\mojom_cpp_generator.py", line 183, in HasPackedMethodOrdinals
    max_ordinal = len(interface.methods) * 2
TypeError: object of type 'map' has no len()

Bug: 941669
Change-Id: I0a3797c57d9345beb8b6f305cb696051366ce9c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2033508
Auto-Submit: Raul Tambre <raul@tambre.ee>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Raul Tambre <raul@tambre.ee>
Cr-Commit-Position: refs/heads/master@{#738182}
parent 1eb76a1a
......@@ -686,8 +686,9 @@ def _Module(tree, path, imports):
del union.fields_data
all_defined_kinds[union.spec] = union
for interface in module.interfaces:
interface.methods = map(lambda method:
_Method(module, method, interface), interface.methods_data)
interface.methods = list(
map(lambda method: _Method(module, method, interface),
interface.methods_data))
del interface.methods_data
all_defined_kinds[interface.spec] = interface
for enum in interface.enums:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment