From: Alexandre Vassalotti Date: Tue, 4 Dec 2007 06:20:30 +0000 (+0000) Subject: Fix issue #1553: An errornous __length_hint__ can make list() raise a X-Git-Tag: v3.0a2~33 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=79a082b7159d697f6b63e967f18e18cee0c82db7;p=thirdparty%2FPython%2Fcpython.git Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError. --- diff --git a/Objects/abstract.c b/Objects/abstract.c index 965d0880d7e2..df5da5fb2cf4 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -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; } diff --git a/Objects/listobject.c b/Objects/listobject.c index 43e8a3f8ae90..59674bf0ee59 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -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; }