[Python-checkins] python/dist/src/Objects abstract.c, 2.137, 2.138 listobject.c, 2.225, 2.226

rhettinger@users.sourceforge.net rhettinger at users.sourceforge.net
Sun Aug 21 13:04:13 CEST 2005


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1877/Objects

Modified Files:
	abstract.c listobject.c 
Log Message:
SF bug #1242657:   list(obj) can swallow KeyboardInterrupt

Fix over-aggressive PyErr_Clear().  The same code fragment appears in
various guises in list.extend(), map(), filter(), zip(), and internally
in PySequence_Tuple().



Index: abstract.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v
retrieving revision 2.137
retrieving revision 2.138
diff -u -d -r2.137 -r2.138
--- abstract.c	12 Jul 2005 10:21:02 -0000	2.137
+++ abstract.c	21 Aug 2005 11:03:56 -0000	2.138
@@ -1401,6 +1401,11 @@
 	/* Guess result size and allocate space. */
 	n = PyObject_Size(v);
 	if (n < 0) {
+		if (!PyErr_ExceptionMatches(PyExc_TypeError)  &&
+		    !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+			Py_DECREF(it);
+			return NULL;
+		}
 		PyErr_Clear();
 		n = 10;  /* arbitrary */
 	}

Index: listobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v
retrieving revision 2.225
retrieving revision 2.226
diff -u -d -r2.225 -r2.226
--- listobject.c	7 Oct 2004 03:58:07 -0000	2.225
+++ listobject.c	21 Aug 2005 11:03:57 -0000	2.226
@@ -777,6 +777,11 @@
 	/* Guess a result list size. */
 	n = PyObject_Size(b);
 	if (n < 0) {
+		if (!PyErr_ExceptionMatches(PyExc_TypeError)  &&
+		    !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+			Py_DECREF(it);
+			return NULL;
+		}
 		PyErr_Clear();
 		n = 8;	/* arbitrary */
 	}



More information about the Python-checkins mailing list