
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2017-09-29 20:21 bychristian.heimes, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 3834 | merged | serhiy.storchaka,2017-09-30 06:47 | |
| PR 3923 | merged | serhiy.storchaka,2017-10-08 08:15 | |
| Messages (5) | |||
|---|---|---|---|
| msg303356 -(view) | Author: Christian Heimes (christian.heimes)*![]() | Date: 2017-09-29 20:21 | |
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 NoneTrue>>> import a.bTraceback (most recent call last): File "<stdin>", line 1, in <module>ModuleNotFoundError: import of 'a.b' halted; None in sys.modulesTests 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" | |||
| msg303374 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-09-29 23:42 | |
This is a side effect ofissue15767. The exception is raised in _find_and_load, but it is always silenced in _handle_fromlist. | |||
| msg303396 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-09-30 06:56 | |
PR 3834 provide possible solution of this issue.Initially import errors were silenced for solvingissue15715. An import error raised when import was blocked by setting None in sys.modules was not silenced because it has different error message. I don't know whether this was intentional. Inissue15767 (5fdb8c897023) the error message test was replaced by the type test, and that exception become silenced (I suppose it was not intentional). | |||
| msg303900 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-10-08 07:44 | |
New changesetf07e2b64df6304a36fb5e29397d3c77a7ba17704 by Serhiy Storchaka in branch 'master':bpo-31642: Restore blocking "from" import by setting None in sys.modules. (#3834)https://github.com/python/cpython/commit/f07e2b64df6304a36fb5e29397d3c77a7ba17704 | |||
| msg303904 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-10-08 09:52 | |
New changeset6f059ab80a351a7dd85cc57c5ca240f817a79c5d by Serhiy Storchaka in branch '3.6':[3.6]bpo-31642: Restore blocking "from" import by setting None in sys.modules. (GH-3834). (#3923)https://github.com/python/cpython/commit/6f059ab80a351a7dd85cc57c5ca240f817a79c5d | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:52 | admin | set | github: 75823 |
| 2017-10-08 09:55:13 | serhiy.storchaka | set | status: open -> closed stage: patch review -> resolved resolution: fixed versions: - Python 3.8 |
| 2017-10-08 09:52:00 | serhiy.storchaka | set | messages: +msg303904 |
| 2017-10-08 08:15:31 | serhiy.storchaka | set | pull_requests: +pull_request3896 |
| 2017-10-08 07:44:12 | serhiy.storchaka | set | messages: +msg303900 |
| 2017-09-30 06:56:34 | serhiy.storchaka | set | messages: +msg303396 |
| 2017-09-30 06:47:08 | serhiy.storchaka | set | keywords: +patch stage: needs patch -> patch review pull_requests: +pull_request3815 |
| 2017-09-29 23:42:25 | serhiy.storchaka | set | messages: +msg303374 |
| 2017-09-29 20:32:45 | barry | set | nosy: +barry |
| 2017-09-29 20:23:21 | serhiy.storchaka | set | nosy: +serhiy.storchaka |
| 2017-09-29 20:22:23 | christian.heimes | set | type: behavior stage: needs patch |
| 2017-09-29 20:22:13 | christian.heimes | set | nosy: +brett.cannon,ncoghlan,eric.snow |
| 2017-09-29 20:21:12 | christian.heimes | create | |