From: Georg Brandl Date: Wed, 14 Sep 2005 06:56:20 +0000 (+0000) Subject: Patch #1290454: Fix reload() error message when parent module is not in X-Git-Tag: v2.5a0~1385 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0c55f2946b559bd5f6dec457accdc2f2c9c55d3a;p=thirdparty%2FPython%2Fcpython.git Patch #1290454: Fix reload() error message when parent module is not in sys.modules. --- diff --git a/Python/import.c b/Python/import.c index c03d4ccf28c0..7cd5813949f9 100644 --- a/Python/import.c +++ b/Python/import.c @@ -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)