mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Have importlib raise ImportError if None is found in sys.modules. This matches
current import semantics.
This commit is contained in:
parent
ccd686a473
commit
4d75fc1ce9
3 changed files with 22 additions and 5 deletions
|
@ -864,7 +864,12 @@ def _gcd_import(name, package=None, level=0):
|
|||
name = package[:dot]
|
||||
with _ImportLockContext():
|
||||
try:
|
||||
return sys.modules[name]
|
||||
module = sys.modules[name]
|
||||
if module is None:
|
||||
message = ("import of {} halted; "
|
||||
"None in sys.modules".format(name))
|
||||
raise ImportError(message)
|
||||
return module
|
||||
except KeyError:
|
||||
pass
|
||||
parent = name.rpartition('.')[0]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue