From 8f5ac5106eb24dd8bda91f25e993a90a820a2d5c Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 12 Jun 2013 23:29:18 -0400 Subject: Issue #15767: Touch up ModuleNotFoundError usage by import. Forgot to raise ModuleNotFoundError when None is found in sys.modules. This led to introducing the C function PyErr_SetImportErrorSubclass() to make setting ModuleNotFoundError easier. Also updated the reference docs to mention ModuleNotFoundError appropriately. Updated the docs for ModuleNotFoundError to mention the None in sys.modules case. Lastly, it was noticed that PyErr_SetImportError() was not setting an exception when returning None in one case. That issue is now fixed. --- Lib/importlib/_bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib') diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index cd41336aab..9a82bd1ee5 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -1614,7 +1614,7 @@ def _gcd_import(name, package=None, level=0): _imp.release_lock() message = ("import of {} halted; " "None in sys.modules".format(name)) - raise ImportError(message, name=name) + raise ModuleNotFoundError(message, name=name) _lock_unlock_module(name) return module -- cgit v1.2.1