Kaydet (Commit) 0c55f294 authored tarafından Georg Brandl's avatar Georg Brandl

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

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