Commit 9099bf10 authored by Raul Tambre's avatar Raul Tambre Committed by Commit Bot

build_utils.py: itervalues() Python 3 fix

itervalues() has been removed in Python 3 in favour of values().
They're functionally equivalent, but values() is slightly slower in Python 2. In this case there shouldn't be a difference because sys.modules is usually pretty small.

Example backtrace:
Traceback (most recent call last):
  File "../../tools/licenses.py", line 809, in <module>
    sys.exit(main())
  File "../../tools/licenses.py", line 791, in main
    if not GenerateCredits(args.file_template, args.entry_template,
  File "../../tools/licenses.py", line 717, in GenerateCredits
    build_utils.WriteDepfile(depfile, output_file,
  File "C:\Google\chromium\src\build/android/gyp\util\build_utils.py", line 563, in WriteDepfile
    inputs = _ComputePythonDependencies() + inputs
  File "C:\Google\chromium\src\build/android/gyp\util\build_utils.py", line 514, in _ComputePythonDependencies
    module_paths = (m.__file__ for m in sys.modules.itervalues()
AttributeError: 'dict' object has no attribute 'itervalues'

Bug: 941669
Change-Id: I3a5e1602f3dda99ea97f328811d941de73cb76eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857124
Auto-Submit: Raul Tambre <raul@tambre.ee>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706004}
parent ffd9c301
...@@ -511,7 +511,7 @@ def _ComputePythonDependencies(): ...@@ -511,7 +511,7 @@ def _ComputePythonDependencies():
src/. The paths will be relative to the current directory. src/. The paths will be relative to the current directory.
""" """
_ForceLazyModulesToLoad() _ForceLazyModulesToLoad()
module_paths = (m.__file__ for m in sys.modules.itervalues() module_paths = (m.__file__ for m in sys.modules.values()
if m is not None and hasattr(m, '__file__')) if m is not None and hasattr(m, '__file__'))
abs_module_paths = map(os.path.abspath, module_paths) abs_module_paths = map(os.path.abspath, module_paths)
......
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