bpo-31642: Restore blocking "from" import by setting None in sys.modules. (#3834)

This commit is contained in:
Serhiy Storchaka 2017-10-08 10:44:10 +03:00 committed by GitHub
parent 73ffd3f203
commit f07e2b64df
4 changed files with 262 additions and 243 deletions

View file

@ -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