]> granicus.if.org Git - python/commitdiff
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can...
authorChristian Heimes <christian@cheimes.de>
Wed, 5 Dec 2007 12:51:23 +0000 (12:51 +0000)
committerChristian Heimes <christian@cheimes.de>
Wed, 5 Dec 2007 12:51:23 +0000 (12:51 +0000)
Misc/NEWS
Objects/abstract.c
Objects/listobject.c

index 735b073bd1e0316c9946c240119d71c6ae42c333..24a43f09d438ddb8c9321cb07875a6955bb542e3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.5.2c1?
 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
index f7a3bfefb6cc6f20b8bdd1068b4d053138b76222..fb123db6f7894df242e47601d63589495db17ba4 100644 (file)
@@ -1507,8 +1507,9 @@ PySequence_Tuple(PyObject *v)
        /* 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;
                }
index 75ba6d071a3408a17dffe03c7333562480f7d49e..c0d0e090dfa239038544e661bfc9730f059db009 100644 (file)
@@ -784,8 +784,9 @@ listextend(PyListObject *self, PyObject *b)
        /* 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;
                }