]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix issue #1553: An errornous __length_hint__ can make list() raise a
authorAlexandre Vassalotti <alexandre@peadrop.com>
Tue, 4 Dec 2007 06:20:30 +0000 (06:20 +0000)
committerAlexandre Vassalotti <alexandre@peadrop.com>
Tue, 4 Dec 2007 06:20:30 +0000 (06:20 +0000)
SystemError.

Objects/abstract.c
Objects/listobject.c

index 965d0880d7e27105eb3d797b5149a8978537f2ab..df5da5fb2cf462f16ab8cd67ee7db3db5c90ebe8 100644 (file)
@@ -1657,8 +1657,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 43e8a3f8ae90421f0df0fe82b25e0f866aecf235..59674bf0ee591003322db9f7695fcff97135facf 100644 (file)
@@ -760,8 +760,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;
                }