summaryrefslogtreecommitdiff
path: root/Lib/importlib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-10-08 10:44:10 +0300
committerGitHub <noreply@github.com>2017-10-08 10:44:10 +0300
commitf07e2b64df6304a36fb5e29397d3c77a7ba17704 (patch)
treeab3e39e6fd0354efc337ed87c068346b16a3f8f9 /Lib/importlib
parent73ffd3f2036179ed54591ef0455e5ba5694ae5bd (diff)
downloadcpython-git-f07e2b64df6304a36fb5e29397d3c77a7ba17704.tar.gz
bpo-31642: Restore blocking "from" import by setting None in sys.modules. (#3834)
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_bootstrap.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 755a634465..76e1be5968 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -1019,7 +1019,8 @@ def _handle_fromlist(module, fromlist, import_):
# Backwards-compatibility dictates we ignore failed
# imports triggered by fromlist for modules that don't
# exist.
- if exc.name == from_name:
+ if (exc.name == from_name and
+ sys.modules.get(from_name, _NEEDS_LOADING) is not None):
continue
raise
return module