Patch #1290454: Fix reload() error message when parent module is not in

sys.modules.
This commit is contained in:
Georg Brandl 2005-09-14 06:56:20 +00:00
parent 14f4fd0a9e
commit 0c55f2946b
1 changed files with 3 additions and 2 deletions

View File

@ -2288,13 +2288,14 @@ PyImport_ReloadModule(PyObject *m)
if (parentname == NULL)
return NULL;
parent = PyDict_GetItem(modules, parentname);
Py_DECREF(parentname);
if (parent == NULL) {
PyErr_Format(PyExc_ImportError,
"reload(): parent %.200s not in sys.modules",
name);
PyString_AS_STRING(parentname));
Py_DECREF(parentname);
return NULL;
}
Py_DECREF(parentname);
subname++;
path = PyObject_GetAttrString(parent, "__path__");
if (path == NULL)