[issue37521] importlib.util.module_from_spec return value is not the same as in sys.modules

Benjamin Mintz report at bugs.python.org
Sun Jul 7 20:52:26 EDT 2019


New submission from Benjamin Mintz <benjabean1 at gmail.com>:

unzip the attached zip file and run main.py

expected output:

True
<module 'testext.sub' (namespace)>

actual output:
False
<module 'testext.sub' (namespace)>

So what?
If you follow these directions, https://docs.python.org/3.7/library/importlib.html#checking-if-a-module-can-be-imported , you will put a stale reference in sys.modules even though a fresh reference is already there. If you use that code on a package with a subpackage, the subpackage will not be set as an attribute on the package.

----------
components: Library (Lib)
files: importsfucked.zip
messages: 347482
nosy: bmintz
priority: normal
severity: normal
status: open
title: importlib.util.module_from_spec return value is not the same as in sys.modules
versions: Python 3.7
Added file: https://bugs.python.org/file48460/importsfucked.zip

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37521>
_______________________________________


More information about the Python-bugs-list mailing list