Commit d3aed038 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.

The backtrace line for tmpl_39c97377bd70465296e9ef54393504d947e7fcc4.py actually refers to the line in module-forward.h.tmpl.
Pretty annoying to trace down!

Traceback (most recent call last):
  File "../../mojo/public/tools/bindings/mojom_bindings_generator.py", line 562, in <module>
    sys.exit(main())
  File "../../mojo/public/tools/bindings/mojom_bindings_generator.py", line 557, in main
    return args.func(args, remaining_args)
  File "../../mojo/public/tools/bindings/mojom_bindings_generator.py", line 268, in _Generate
    processor._GenerateModule(args, remaining_args, generator_modules,
  File "../../mojo/public/tools/bindings/mojom_bindings_generator.py", line 239, in _GenerateModule
    generator.GenerateFiles(filtered_args)
  File "C:\Google\chromium\src\mojo\public\tools\bindings\generators\mojom_cpp_generator.py", line 490, in GenerateFiles
    self.WriteWithComment(self._GenerateModuleForwardHeader(),
  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 31, 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_39c97377bd70465296e9ef54393504d947e7fcc4.py", line 58, in <module>
TypeError: object of type 'map' has no len()

Bug: 941669
Change-Id: Ie00e7a9537f9ae0ac10b8a91c320fc37e7818fd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2050376
Auto-Submit: Raul Tambre <raul@tambre.ee>
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#740479}
parent 09f88684
...@@ -666,9 +666,9 @@ def _Module(tree, path, imports): ...@@ -666,9 +666,9 @@ def _Module(tree, path, imports):
module.interfaces = list( module.interfaces = list(
map(lambda interface: _Interface(module, interface), map(lambda interface: _Interface(module, interface),
_ElemsOfType(tree.definition_list, ast.Interface, filename))) _ElemsOfType(tree.definition_list, ast.Interface, filename)))
module.constants = map( module.constants = list(
lambda constant: _Constant(module, constant, None), map(lambda constant: _Constant(module, constant, None),
_ElemsOfType(tree.definition_list, ast.Const, filename)) _ElemsOfType(tree.definition_list, ast.Const, filename)))
# Second pass expands fields and methods. This allows fields and parameters # Second pass expands fields and methods. This allows fields and parameters
# to refer to kinds defined anywhere in the mojom. # to refer to kinds defined anywhere in the mojom.
......
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