Mercurial > cpython-lru_cache-weakref
diff Lib/importlib/_bootstrap.py @ 81884:19ea454ccdf7 3.3
Issue #17098: Be more stringent of setting __loader__ on early imported
modules. Also made test more rigorous.
| author | Brett Cannon <brett@python.org> |
|---|---|
| date | Fri, 01 Feb 2013 15:31:49 -0500 |
| parents | 05747d3bcd9c |
| children | 0f65bf6063ca 306f066e6a33 |
line wrap: on
line diff
--- a/Lib/importlib/_bootstrap.py Fri Feb 01 14:43:59 2013 -0500 +++ b/Lib/importlib/_bootstrap.py Fri Feb 01 15:31:49 2013 -0500 @@ -1704,10 +1704,13 @@ BYTECODE_SUFFIXES = DEBUG_BYTECODE_SUFFIXES module_type = type(sys) - for module in sys.modules.values(): + for name, module in sys.modules.items(): if isinstance(module, module_type): if not hasattr(module, '__loader__'): - module.__loader__ = BuiltinImporter + if name in sys.builtin_module_names: + module.__loader__ = BuiltinImporter + elif _imp.is_frozen(name): + module.__loader__ = FrozenImporter self_module = sys.modules[__name__] for builtin_name in ('_io', '_warnings', 'builtins', 'marshal'):
