Commit 27fc5287 authored by Brett Cannon's avatar Brett Cannon

Set ImportError.name when raising the exception in the case of None

found in sys.modules.
parent da4210f7
...@@ -2980,8 +2980,11 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals, ...@@ -2980,8 +2980,11 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals,
mod = PyDict_GetItem(interp->modules, abs_name); mod = PyDict_GetItem(interp->modules, abs_name);
if (mod == Py_None) { if (mod == Py_None) {
PyErr_Format(PyExc_ImportError, PyObject *msg = PyUnicode_FromFormat("import of %R halted; "
"import of %R halted; None in sys.modules", abs_name); "None in sys.modules", abs_name);
if (msg != NULL) {
PyErr_SetFromImportErrorWithName(msg, abs_name);
}
goto error_with_unlock; goto error_with_unlock;
} }
else if (mod != NULL) { else if (mod != NULL) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment