Merged revisions 74584 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r74584 | brett.cannon | 2009-08-29 20:47:36 -0700 (Sat, 29 Aug 2009) | 3 lines

  Have importlib raise ImportError if None is found in sys.modules. This matches
  current import semantics.
........
This commit is contained in:
Brett Cannon 2009-08-30 04:29:47 +00:00
parent af0312af7a
commit 8a1a59f0ec
3 changed files with 23 additions and 5 deletions

View file

@ -860,7 +860,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]