mirror of
https://github.com/python/cpython.git
synced 2025-07-30 14:44:10 +00:00
Merge fix for issue #15111.
This commit is contained in:
commit
9407d50208
4 changed files with 489 additions and 469 deletions
|
@ -1602,19 +1602,19 @@ def _handle_fromlist(module, fromlist, import_):
|
|||
fromlist.extend(module.__all__)
|
||||
for x in fromlist:
|
||||
if not hasattr(module, x):
|
||||
from_name = '{}.{}'.format(module.__name__, x)
|
||||
try:
|
||||
_call_with_frames_removed(import_,
|
||||
'{}.{}'.format(module.__name__, x))
|
||||
_call_with_frames_removed(import_, from_name)
|
||||
except ImportError as exc:
|
||||
# Backwards-compatibility dictates we ignore failed
|
||||
# imports triggered by fromlist for modules that don't
|
||||
# exist.
|
||||
# TODO(brett): In Python 3.4, have import raise
|
||||
# ModuleNotFound and catch that.
|
||||
if hasattr(exc, '_not_found') and exc._not_found:
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
if getattr(exc, '_not_found', False):
|
||||
if exc.name == from_name:
|
||||
continue
|
||||
raise
|
||||
return module
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue