diff Python/import.c @ 35543:25378bdb1b3a 2.4

Backport of patch #1290454: Fix reload() error message when parent is not in sys.modules.
author Georg Brandl <georg@python.org>
date Wed, 14 Sep 2005 06:56:51 +0000
parents bcafb68ad985
children 57f630a9de26
line wrap: on
line diff
--- a/Python/import.c	Mon Sep 12 12:56:47 2005 +0000
+++ b/Python/import.c	Wed Sep 14 06:56:51 2005 +0000
@@ -2298,13 +2298,14 @@
 		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)