New submission from Christian Heimes <li...@cheimes.de>: Since Python 3.6, the blocking of imports is broken for 'from package import module' imports.
$ mkdir a $ touch a/__init__.py a/b.py >>> import sys >>> sys.modules['a.b'] = None >>> from a import b >>> b is None True >>> import a.b Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: import of 'a.b' halted; None in sys.modules Tests with Python 2.7 to master: $ python2.7 -c "from a import b; print(b)" <module 'a.b' from 'a/b.py'> $ python2.7 -c "import sys; sys.modules['a.b'] = None; from a import b" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: cannot import name b $ python2.7 -c "import sys; sys.modules['a.b'] = None; from a import b" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: cannot import name b $ python3.4 -c "import sys; sys.modules['a.b'] = None; from a import b" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: import of 'a.b' halted; None in sys.modules $ python3.5 -c "import sys; sys.modules['a.b'] = None; from a import b" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: import of 'a.b' halted; None in sys.modules $ python3.6 -c "import sys; sys.modules['a.b'] = None; from a import b" $ ./python -c "import sys; sys.modules['a.b'] = None; from a import b" ---------- components: Interpreter Core keywords: 3.6regression messages: 303356 nosy: christian.heimes priority: normal severity: normal status: open title: None value in sys.modules no longer blocks import versions: Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31642> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com