diff options
author | Géry Ogam <gery.ogam@gmail.com> | 2019-05-01 20:08:17 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2019-05-01 20:08:17 (GMT) |
commit | ee88af3f4f7493df4ecf52faf429e63351bbcd5c (patch) | |
tree | 711dbee54c850ae97de7d3ac7cfceb323df501b8 /Doc/reference | |
parent | dde3eebdaa8d2c51971ca704d53af7cbcda8bb34 (diff) | |
download | cpython-ee88af3f4f7493df4ecf52faf429e63351bbcd5c.zip cpython-ee88af3f4f7493df4ecf52faf429e63351bbcd5c.tar.gz cpython-ee88af3f4f7493df4ecf52faf429e63351bbcd5c.tar.bz2 |
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
Diffstat (limited to 'Doc/reference')
-rw-r--r-- | Doc/reference/import.rst | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Doc/reference/import.rst b/Doc/reference/import.rst index 88290c8..0228bfb 100644 --- a/Doc/reference/import.rst +++ b/Doc/reference/import.rst @@ -345,12 +345,11 @@ of what happens during the loading portion of import:: _init_module_attrs(spec, module) if spec.loader is None: - if spec.submodule_search_locations is not None: - # namespace package - sys.modules[spec.name] = module - else: - # unsupported - raise ImportError + # unsupported + raise ImportError + if spec.origin is None and spec.submodule_search_locations is not None: + # namespace package + sys.modules[spec.name] = module elif not hasattr(spec.loader, 'exec_module'): module = spec.loader.load_module(spec.name) # Set __loader__ and __package__ if missing. |