]> granicus.if.org Git - python/commitdiff
Patch #1290454: Fix reload() error message when parent module is not in
authorGeorg Brandl <georg@python.org>
Wed, 14 Sep 2005 06:56:20 +0000 (06:56 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 14 Sep 2005 06:56:20 +0000 (06:56 +0000)
sys.modules.

Python/import.c

index c03d4ccf28c0c11c4e80328aa409b04c448881fa..7cd5813949f9691f4f9bf6ecce056ea9dd596efc 100644 (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)