Author: alexandre.vassalotti
Date: Tue Dec  4 07:20:30 2007
New Revision: 59316

Modified:
   python/branches/py3k/Objects/abstract.c
   python/branches/py3k/Objects/listobject.c
Log:
Fix issue #1553: An errornous __length_hint__ can make list() raise a
SystemError.


Modified: python/branches/py3k/Objects/abstract.c
==============================================================================
--- python/branches/py3k/Objects/abstract.c     (original)
+++ python/branches/py3k/Objects/abstract.c     Tue Dec  4 07:20:30 2007
@@ -1657,8 +1657,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/py3k/Objects/listobject.c
==============================================================================
--- python/branches/py3k/Objects/listobject.c   (original)
+++ python/branches/py3k/Objects/listobject.c   Tue Dec  4 07:20:30 2007
@@ -760,8 +760,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;
                }
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to