diff options
| author | Brett Cannon <bcannon@gmail.com> | 2009-08-30 03:47:36 (GMT) |
|---|---|---|
| committer | Brett Cannon <bcannon@gmail.com> | 2009-08-30 03:47:36 (GMT) |
| commit | 4d75fc1ce97bd15126442c16faab8931aaa7ade2 (patch) | |
| tree | 4558c370a531f7f3a82b128361ea9d1236b99211 /Lib/importlib/_bootstrap.py | |
| parent | ccd686a47336bfbd70614824465f5793fd69a685 (diff) | |
| download | cpython-4d75fc1ce97bd15126442c16faab8931aaa7ade2.zip cpython-4d75fc1ce97bd15126442c16faab8931aaa7ade2.tar.gz cpython-4d75fc1ce97bd15126442c16faab8931aaa7ade2.tar.bz2 | |
Have importlib raise ImportError if None is found in sys.modules. This matches
current import semantics.
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
| -rw-r--r-- | Lib/importlib/_bootstrap.py | 7 |
1 files changed, 6 insertions, 1 deletions
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 @@ 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] |
