Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0c55f29

Browse files
committed
Patch #1290454: Fix reload() error message when parent module is not in
sys.modules.
1 parent 14f4fd0 commit 0c55f29

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Python/import.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,13 +2288,14 @@ PyImport_ReloadModule(PyObject *m)
22882288
if (parentname == NULL)
22892289
return NULL;
22902290
parent = PyDict_GetItem(modules, parentname);
2291-
Py_DECREF(parentname);
22922291
if (parent == NULL) {
22932292
PyErr_Format(PyExc_ImportError,
22942293
"reload(): parent %.200s not in sys.modules",
2295-
name);
2294+
PyString_AS_STRING(parentname));
2295+
Py_DECREF(parentname);
22962296
return NULL;
22972297
}
2298+
Py_DECREF(parentname);
22982299
subname++;
22992300
path = PyObject_GetAttrString(parent, "__path__");
23002301
if (path == NULL)

0 commit comments

Comments
 (0)