diff Python/import.c @ 41139:9db3e325dd88 legacy-trunk

Fix some style nits: * lines too long * wrong indentation * space after a function name * wrong function name in error string * simplifying some logic Also add an error check to PyDict_SetItemString.
author Neal Norwitz <nnorwitz@gmail.com>
date Tue, 13 Mar 2007 05:31:38 +0000
parents 45ce388ec59a
children 894691ca4835
line wrap: on
line diff
--- a/Python/import.c	Tue Mar 13 05:07:14 2007 +0000
+++ b/Python/import.c	Tue Mar 13 05:31:38 2007 +0000
@@ -345,18 +345,17 @@
 {
 	PyInterpreterState *interp = PyThreadState_Get()->interp;
 	if (interp->modules_reloading == NULL)
-		Py_FatalError("PyImport_GetModuleDict: no modules_reloading dictionary!");
+		Py_FatalError("PyImport_GetModulesReloading: "
+			      "no modules_reloading dictionary!");
 	return interp->modules_reloading;
 }
 
 static void
-imp_modules_reloading_clear (void)
+imp_modules_reloading_clear(void)
 {
 	PyInterpreterState *interp = PyThreadState_Get()->interp;
-	if (interp->modules_reloading == NULL)
-		return;
-	PyDict_Clear(interp->modules_reloading);
-	return;
+	if (interp->modules_reloading != NULL)
+		PyDict_Clear(interp->modules_reloading);
 }
 
 /* Helper for sys */
@@ -2444,12 +2443,15 @@
 			     name);
 		return NULL;
 	}
-	if ((existing_m = PyDict_GetItemString(modules_reloading, name)) != NULL) {
-        /* Due to a recursive reload, this module is already being reloaded. */
-        Py_INCREF(existing_m);
-        return existing_m;
+	existing_m = PyDict_GetItemString(modules_reloading, name);
+	if (existing_m != NULL) {
+		/* Due to a recursive reload, this module is already
+		   being reloaded. */
+		Py_INCREF(existing_m);
+		return existing_m;
  	}
- 	PyDict_SetItemString(modules_reloading, name, m);
+ 	if (PyDict_SetItemString(modules_reloading, name, m) < 0)
+		return NULL;
 
 	subname = strrchr(name, '.');
 	if (subname == NULL)
@@ -2460,7 +2462,7 @@
 		if (parentname == NULL) {
 			imp_modules_reloading_clear();
 			return NULL;
-        }
+        	}
 		parent = PyDict_GetItem(modules, parentname);
 		if (parent == NULL) {
 			PyErr_Format(PyExc_ImportError,
@@ -2499,7 +2501,7 @@
 		 */
 		PyDict_SetItemString(modules, name, m);
 	}
-	imp_modules_reloading_clear ();
+	imp_modules_reloading_clear();
 	return newm;
 }