mirror of
https://github.com/python/cpython.git
synced 2025-07-16 15:55:18 +00:00
Set ImportError.name when raising the exception in the case of None
found in sys.modules.
This commit is contained in:
parent
da4210f77d
commit
27fc52877c
1 changed files with 5 additions and 2 deletions
|
@ -2980,8 +2980,11 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals,
|
|||
|
||||
mod = PyDict_GetItem(interp->modules, abs_name);
|
||||
if (mod == Py_None) {
|
||||
PyErr_Format(PyExc_ImportError,
|
||||
"import of %R halted; None in sys.modules", abs_name);
|
||||
PyObject *msg = PyUnicode_FromFormat("import of %R halted; "
|
||||
"None in sys.modules", abs_name);
|
||||
if (msg != NULL) {
|
||||
PyErr_SetFromImportErrorWithName(msg, abs_name);
|
||||
}
|
||||
goto error_with_unlock;
|
||||
}
|
||||
else if (mod != NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue