Have importlib raise ImportError if None is found in sys.modules. This matches
current import semantics.
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index 2c5a1cf..079a9b2 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -864,7 +864,12 @@
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]