]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport of patch #1290454: Fix reload() error message when parent is not
authorGeorg Brandl <georg@python.org>
Wed, 14 Sep 2005 06:56:51 +0000 (06:56 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 14 Sep 2005 06:56:51 +0000 (06:56 +0000)
in sys.modules.

Python/import.c

index 75c6d3e93ba56ea5c0770379c83574af42e2edc1..72a5605271f0c27371256f32006870f05095de1f 100644 (file)
@@ -2298,13 +2298,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)