Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import ast | 5 import ast |
| 6 import contextlib | 6 import contextlib |
| 7 import fnmatch | 7 import fnmatch |
| 8 import json | 8 import json |
| 9 import os | 9 import os |
| 10 import pipes | 10 import pipes |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 | 399 |
| 400 return sorted_deps | 400 return sorted_deps |
| 401 | 401 |
| 402 | 402 |
| 403 def GetPythonDependencies(): | 403 def GetPythonDependencies(): |
| 404 """Gets the paths of imported non-system python modules. | 404 """Gets the paths of imported non-system python modules. |
| 405 | 405 |
| 406 A path is assumed to be a "system" import if it is outside of chromium's | 406 A path is assumed to be a "system" import if it is outside of chromium's |
| 407 src/. The paths will be relative to the current directory. | 407 src/. The paths will be relative to the current directory. |
| 408 """ | 408 """ |
| 409 module_paths = (m.__file__ for m in sys.modules.itervalues() | 409 # Don't use sys.modules.itervalues() here. Inspecting the modules causes |
| 410 # lazily imported modules (e.g. from email) to get fully imported and update | |
| 411 # sys.modules. This causes a runtime error when iterating with itervalues(). | |
| 412 module_paths = (m.__file__ for m in sys.modules.values() | |
|
agrieve
2016/12/14 15:35:28
If it's being updated during iteration, then we're
| |
| 410 if m is not None and hasattr(m, '__file__')) | 413 if m is not None and hasattr(m, '__file__')) |
| 411 | 414 |
| 412 abs_module_paths = map(os.path.abspath, module_paths) | 415 abs_module_paths = map(os.path.abspath, module_paths) |
| 413 | 416 |
| 414 assert os.path.isabs(host_paths.DIR_SOURCE_ROOT) | 417 assert os.path.isabs(host_paths.DIR_SOURCE_ROOT) |
| 415 non_system_module_paths = [ | 418 non_system_module_paths = [ |
| 416 p for p in abs_module_paths if p.startswith(host_paths.DIR_SOURCE_ROOT)] | 419 p for p in abs_module_paths if p.startswith(host_paths.DIR_SOURCE_ROOT)] |
| 417 def ConvertPycToPy(s): | 420 def ConvertPycToPy(s): |
| 418 if s.endswith('.pyc'): | 421 if s.endswith('.pyc'): |
| 419 return s[:-1] | 422 return s[:-1] |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 | 550 |
| 548 md5_check.CallAndRecordIfStale( | 551 md5_check.CallAndRecordIfStale( |
| 549 on_stale_md5, | 552 on_stale_md5, |
| 550 record_path=record_path, | 553 record_path=record_path, |
| 551 input_paths=input_paths, | 554 input_paths=input_paths, |
| 552 input_strings=input_strings, | 555 input_strings=input_strings, |
| 553 output_paths=output_paths, | 556 output_paths=output_paths, |
| 554 force=force, | 557 force=force, |
| 555 pass_changes=True) | 558 pass_changes=True) |
| 556 | 559 |
| OLD | NEW |