From: Georg Brandl Date: Wed, 14 Sep 2005 06:56:51 +0000 (+0000) Subject: Backport of patch #1290454: Fix reload() error message when parent is not X-Git-Tag: v2.4.2c1~39 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=32cb7f080dea6b99db52dd15fbc8a1e1eba88748;p=thirdparty%2FPython%2Fcpython.git Backport of patch #1290454: Fix reload() error message when parent is not in sys.modules. --- diff --git a/Python/import.c b/Python/import.c index 75c6d3e93ba5..72a5605271f0 100644 --- a/Python/import.c +++ b/Python/import.c @@ -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)