diff options
author | Christian Heimes <christian@cheimes.de> | 2007-12-05 12:49:14 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-12-05 12:49:14 (GMT) |
commit | fe4826f6ace6076b4ded9275b5ad5bdb04017b55 (patch) | |
tree | 9bdf0e23b4454b265e29e26140b9be89a1ba7cd6 /Objects | |
parent | 8f1fea50617766f79171102dd68449692d98fc1f (diff) | |
download | cpython-fe4826f6ace6076b4ded9275b5ad5bdb04017b55.zip cpython-fe4826f6ace6076b4ded9275b5ad5bdb04017b55.tar.gz cpython-fe4826f6ace6076b4ded9275b5ad5bdb04017b55.tar.bz2 |
merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/abstract.c | 5 | ||||
-rw-r--r-- | Objects/listobject.c | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 46288dd..1cb4ef8 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -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; } diff --git a/Objects/listobject.c b/Objects/listobject.c index deb3ca5..8389a86 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -796,8 +796,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; } |