[Python-checkins] r59351 - in python/branches/release25-maint: Misc/NEWS Objects/abstract.c Objects/listobject.c

christian.heimes python-checkins at python.org
Wed Dec 5 13:51:24 CET 2007


Author: christian.heimes
Date: Wed Dec  5 13:51:23 2007
New Revision: 59351

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

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Wed Dec  5 13:51:23 2007
@@ -12,6 +12,9 @@
 Core and builtins
 -----------------
 
+- Issue #1553: An errornous __length_hint__ can make list() raise a 
+  SystemError.
+
 - Issue #1521: On 64bit platforms, using PyArgs_ParseTuple with the t# of w#
   format code incorrectly truncated the length to an int, even when
   PY_SSIZE_T_CLEAN is set.  The str.decode method used to return incorrect

Modified: python/branches/release25-maint/Objects/abstract.c
==============================================================================
--- python/branches/release25-maint/Objects/abstract.c	(original)
+++ python/branches/release25-maint/Objects/abstract.c	Wed Dec  5 13:51:23 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/branches/release25-maint/Objects/listobject.c
==============================================================================
--- python/branches/release25-maint/Objects/listobject.c	(original)
+++ python/branches/release25-maint/Objects/listobject.c	Wed Dec  5 13:51:23 2007
@@ -784,8 +784,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