[Python-checkins] r59350 - python/trunk/Objects/abstract.c python/trunk/Objects/listobject.c

christian.heimes python-checkins at python.org
Wed Dec 5 13:49:15 CET 2007


Author: christian.heimes
Date: Wed Dec  5 13:49:14 2007
New Revision: 59350

Modified:
   python/trunk/Objects/abstract.c
   python/trunk/Objects/listobject.c
Log:
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError

Modified: python/trunk/Objects/abstract.c
==============================================================================
--- python/trunk/Objects/abstract.c	(original)
+++ python/trunk/Objects/abstract.c	Wed Dec  5 13:49:14 2007
@@ -1507,8 +1507,9 @@
 	/* Guess result size and allocate space. */
 	n = _PyObject_LengthHint(v);
 	if (n < 0) {
-		if (!PyErr_ExceptionMatches(PyExc_TypeError)  &&
-		    !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+		if (PyErr_Occurred()
+		    && !PyErr_ExceptionMatches(PyExc_TypeError)
+		    && !PyErr_ExceptionMatches(PyExc_AttributeError)) {
 			Py_DECREF(it);
 			return NULL;
 		}

Modified: python/trunk/Objects/listobject.c
==============================================================================
--- python/trunk/Objects/listobject.c	(original)
+++ python/trunk/Objects/listobject.c	Wed Dec  5 13:49:14 2007
@@ -796,8 +796,9 @@
 	/* Guess a result list size. */
 	n = _PyObject_LengthHint(b);
 	if (n < 0) {
-		if (!PyErr_ExceptionMatches(PyExc_TypeError)  &&
-		    !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+		if (PyErr_Occurred()
+		    && !PyErr_ExceptionMatches(PyExc_TypeError)
+		    && !PyErr_ExceptionMatches(PyExc_AttributeError)) {
 			Py_DECREF(it);
 			return NULL;
 		}


More information about the Python-checkins mailing list