[Python-3000-checkins] r62598 - python/branches/py3k/Python/bltinmodule.c

georg.brandl python-3000-checkins at python.org
Wed Apr 30 21:47:01 CEST 2008


Author: georg.brandl
Date: Wed Apr 30 21:47:01 2008
New Revision: 62598

Log:
Fix nits in builtin next().


Modified:
   python/branches/py3k/Python/bltinmodule.c

Modified: python/branches/py3k/Python/bltinmodule.c
==============================================================================
--- python/branches/py3k/Python/bltinmodule.c	(original)
+++ python/branches/py3k/Python/bltinmodule.c	Wed Apr 30 21:47:01 2008
@@ -1048,27 +1048,28 @@
 		return NULL;
 	if (!PyIter_Check(it)) {
 		PyErr_Format(PyExc_TypeError,
-			"%.200s object is not an iterator", it->ob_type->tp_name);
+			"%.200s object is not an iterator",
+			it->ob_type->tp_name);
 		return NULL;
 	}
 	
 	res = (*it->ob_type->tp_iternext)(it);
-	if (res == NULL) {
-		if (def) {
-			if (PyErr_Occurred() &&
-			    !PyErr_ExceptionMatches(PyExc_StopIteration))
+	if (res != NULL) {
+		return res;
+	} else if (def != NULL) {
+		if (PyErr_Occurred()) {
+			if(!PyErr_ExceptionMatches(PyExc_StopIteration))
 				return NULL;
 			PyErr_Clear();
-			Py_INCREF(def);
-			return def;
-		} else if (PyErr_Occurred()) {
-			return NULL;
-		} else {
-			PyErr_SetNone(PyExc_StopIteration);
-			return NULL;
 		}
+		Py_INCREF(def);
+		return def;
+	} else if (PyErr_Occurred()) {
+		return NULL;
+	} else {
+		PyErr_SetNone(PyExc_StopIteration);
+		return NULL;
 	}
-	return res;
 }
 
 PyDoc_STRVAR(next_doc,


More information about the Python-3000-checkins mailing list