[Python-checkins] r69691 - in python/branches/py3k: Modules/itertoolsmodule.c

benjamin.peterson python-checkins at python.org
Mon Feb 16 22:28:30 CET 2009


Author: benjamin.peterson
Date: Mon Feb 16 22:28:29 2009
New Revision: 69691

Log:
Merged revisions 69688,69690 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r69688 | benjamin.peterson | 2009-02-16 15:07:52 -0600 (Mon, 16 Feb 2009) | 1 line
  
  fix compiler warnings
........
  r69690 | benjamin.peterson | 2009-02-16 15:23:04 -0600 (Mon, 16 Feb 2009) | 1 line
  
  PyList_Append() can fail
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Modules/itertoolsmodule.c

Modified: python/branches/py3k/Modules/itertoolsmodule.c
==============================================================================
--- python/branches/py3k/Modules/itertoolsmodule.c	(original)
+++ python/branches/py3k/Modules/itertoolsmodule.c	Mon Feb 16 22:28:29 2009
@@ -745,8 +745,10 @@
 	while (1) {
 		item = PyIter_Next(lz->it);
 		if (item != NULL) {
-			if (!lz->firstpass)
-				PyList_Append(lz->saved, item);
+			if (!lz->firstpass && PyList_Append(lz->saved, item)) {
+				Py_DECREF(item);
+				return NULL;
+			}
 			return item;
 		}
 		if (PyErr_Occurred()) {
@@ -2922,8 +2924,8 @@
 			kwlist, &long_cnt, &long_step))
 		return NULL;
 
-	if (long_cnt != NULL && !PyNumber_Check(long_cnt) ||
-		long_step != NULL && !PyNumber_Check(long_step)) {
+	if ((long_cnt != NULL && !PyNumber_Check(long_cnt)) ||
+            (long_step != NULL && !PyNumber_Check(long_step))) {
 			PyErr_SetString(PyExc_TypeError, "a number is required");
 			return NULL;
 	}
@@ -2950,8 +2952,8 @@
 		} else
 			long_cnt = NULL;
 	}
-	assert(cnt != PY_SSIZE_T_MAX && long_cnt == NULL ||
-		   cnt == PY_SSIZE_T_MAX && long_cnt != NULL);
+	assert((cnt != PY_SSIZE_T_MAX && long_cnt == NULL) ||
+               (cnt == PY_SSIZE_T_MAX && long_cnt != NULL));
 
 	/* create countobject structure */
 	lz = (countobject *)type->tp_alloc(type, 0);
@@ -2975,6 +2977,7 @@
 	Py_TYPE(lz)->tp_free(lz);
 }
 
+static int
 count_traverse(countobject *lz, visitproc visit, void *arg)
 {
 	Py_VISIT(lz->long_cnt);
@@ -2985,7 +2988,6 @@
 static PyObject *
 count_nextlong(countobject *lz)
 {
-	static PyObject *one = NULL;
 	PyObject *long_cnt;
 	PyObject *stepped_up;
 


More information about the Python-checkins mailing list