diff options
author | Brett Cannon <brett@python.org> | 2012-04-15 18:15:31 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-04-15 18:15:31 (GMT) |
commit | 27fc52877ce3cabb2ed524ab0f40f8c8e3a45c18 (patch) | |
tree | acdddfda8c1c9bc26f2468cd73a3476a36087ac7 /Python | |
parent | da4210f77d2fe10667b8620d46eb9d3c3fd9e613 (diff) | |
download | cpython-27fc52877ce3cabb2ed524ab0f40f8c8e3a45c18.zip cpython-27fc52877ce3cabb2ed524ab0f40f8c8e3a45c18.tar.gz cpython-27fc52877ce3cabb2ed524ab0f40f8c8e3a45c18.tar.bz2 |
Set ImportError.name when raising the exception in the case of None
found in sys.modules.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/import.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c index 5136d98..d4f5783 100644 --- a/Python/import.c +++ b/Python/import.c @@ -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) { |