Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 76328:c9fb9f5e16e7
Set ImportError.name when raising the exception in the case of None
found in sys.modules.
| author | Brett Cannon <brett@python.org> |
|---|---|
| date | Sun, 15 Apr 2012 14:15:31 -0400 |
| parents | 9e8cbf07068a |
| children | 005fd1fe31ab |
line wrap: on
line diff
--- a/Python/import.c Sun Apr 15 16:32:04 2012 +0100 +++ b/Python/import.c Sun Apr 15 14:15:31 2012 -0400 @@ -2980,8 +2980,11 @@ 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) {
