summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-02-01 20:31:49 (GMT)
committerBrett Cannon <brett@python.org>2013-02-01 20:31:49 (GMT)
commitda9cf0eef8c9cb338ad71330345423c9de2e0a01 (patch)
tree6308525f9a2e565f482746c6b399e808773bef73 /Lib/importlib
parente7387b470876e6f3a2f4b45ed47a7a061c9fdc99 (diff)
downloadcpython-da9cf0eef8c9cb338ad71330345423c9de2e0a01.zip
cpython-da9cf0eef8c9cb338ad71330345423c9de2e0a01.tar.gz
cpython-da9cf0eef8c9cb338ad71330345423c9de2e0a01.tar.bz2
Issue #17098: Be more stringent of setting __loader__ on early imported
modules. Also made test more rigorous.
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_bootstrap.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 320ec64..15fe156 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -1704,10 +1704,13 @@ def _setup(sys_module, _imp_module):
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'):