mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Issue #17098: Be more stringent of setting __loader__ on early imported
modules. Also made test more rigorous.
This commit is contained in:
parent
e7387b4708
commit
da9cf0eef8
3 changed files with 310 additions and 294 deletions
|
|
@ -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'):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue