mirror of
https://github.com/python/cpython.git
synced 2024-11-24 10:24:35 +08:00
Fix issue #1553: An errornous __length_hint__ can make list() raise a
SystemError.
This commit is contained in:
parent
a74169b7c1
commit
79a082b715
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user