Skip to content

Commit ee88af3

Browse files
geryogamwarsaw
authored andcommitted
Namespace packages _bootstrap.ModuleSpec.loader attributes are no longer None (#10376)
Namespace packages _bootstrap.ModuleSpec.loader attributes are no longer `None` _after_ calling the importlib._bootstrap._init_module_attrs function. See: * https://stackoverflow.com/questions/52869541/namespace-package-spec-loader-and-loader-attributes-not-set-to-none * https://bugs.python.org/issue35181
1 parent dde3eeb commit ee88af3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Doc/reference/import.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,11 @@ of what happens during the loading portion of import::
345345
_init_module_attrs(spec, module)
346346

347347
if spec.loader is None:
348-
if spec.submodule_search_locations is not None:
349-
# namespace package
350-
sys.modules[spec.name] = module
351-
else:
352-
# unsupported
353-
raise ImportError
348+
# unsupported
349+
raise ImportError
350+
if spec.origin is None and spec.submodule_search_locations is not None:
351+
# namespace package
352+
sys.modules[spec.name] = module
354353
elif not hasattr(spec.loader, 'exec_module'):
355354
module = spec.loader.load_module(spec.name)
356355
# Set __loader__ and __package__ if missing.

0 commit comments

Comments
 (0)