Message303356
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" | |
| Date | User | Action | Args | | 2017-09-29 20:21:12 | christian.heimes | set | recipients: + christian.heimes | | 2017-09-29 20:21:12 | christian.heimes | set | messageid: <1506716472.27.0.213398074469.issue31642@psf.upfronthosting.co.za> | | 2017-09-29 20:21:12 | christian.heimes | link | issue31642 messages | | 2017-09-29 20:21:12 | christian.heimes | create | | |