summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-02-01 19:04:12 (GMT)
committerBrett Cannon <brett@python.org>2013-02-01 19:04:12 (GMT)
commit0ecd30b4af4f5bd3c9e884a608e0a256ffe8f5fa (patch)
tree0405597273a346a2b543218253fad1b2c3038e64 /Lib/importlib
parent89fa86b0355a2dcfc8bbb5ebc6dfa1092dd82d19 (diff)
downloadcpython-0ecd30b4af4f5bd3c9e884a608e0a256ffe8f5fa.zip
cpython-0ecd30b4af4f5bd3c9e884a608e0a256ffe8f5fa.tar.gz
cpython-0ecd30b4af4f5bd3c9e884a608e0a256ffe8f5fa.tar.bz2
Issue #17098: Make sure every module has __loader__ defined.
Thanks to Thomas Heller for the bug report.
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_bootstrap.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index f647c2b..320ec64 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -1703,9 +1703,11 @@ def _setup(sys_module, _imp_module):
else:
BYTECODE_SUFFIXES = DEBUG_BYTECODE_SUFFIXES
- for module in (_imp, sys):
- if not hasattr(module, '__loader__'):
- module.__loader__ = BuiltinImporter
+ module_type = type(sys)
+ for module in sys.modules.values():
+ if isinstance(module, module_type):
+ if not hasattr(module, '__loader__'):
+ module.__loader__ = BuiltinImporter
self_module = sys.modules[__name__]
for builtin_name in ('_io', '_warnings', 'builtins', 'marshal'):