[Python-checkins] python/dist/src/Python bltinmodule.c, 2.318.2.1, 2.318.2.2

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


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

Modified Files:
      Tag: release24-maint
	bltinmodule.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: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.318.2.1
retrieving revision 2.318.2.2
diff -u -d -r2.318.2.1 -r2.318.2.2
--- bltinmodule.c	19 Jul 2005 22:20:44 -0000	2.318.2.1
+++ bltinmodule.c	21 Aug 2005 11:09:58 -0000	2.318.2.2
@@ -160,6 +160,10 @@
 	/* Guess a result list size. */
 	len = PyObject_Size(seq);
 	if (len < 0) {
+		if (!PyErr_ExceptionMatches(PyExc_TypeError)  &&
+		    !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+			goto Fail_it;
+		}
 		PyErr_Clear();
 		len = 8;	/* arbitrary */
 	}
@@ -801,6 +805,10 @@
 		/* Update len. */
 		curlen = PyObject_Size(curseq);
 		if (curlen < 0) {
+			if (!PyErr_ExceptionMatches(PyExc_TypeError)  &&
+			    !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+				goto Fail_2;
+			}
 			PyErr_Clear();
 			curlen = 8;  /* arbitrary */
 		}
@@ -2002,6 +2010,10 @@
 		PyObject *item = PyTuple_GET_ITEM(args, i);
 		int thislen = PyObject_Size(item);
 		if (thislen < 0) {
+			if (!PyErr_ExceptionMatches(PyExc_TypeError)  &&
+			    !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+				return NULL;
+			}
 			PyErr_Clear();
 			len = -1;
 			break;



More information about the Python-checkins mailing list