merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError
This commit is contained in:
parent
8f1fea5061
commit
fe4826f6ac
|
@ -1507,8 +1507,9 @@ PySequence_Tuple(PyObject *v)
|
||||||
/* Guess result size and allocate space. */
|
/* Guess result size and allocate space. */
|
||||||
n = _PyObject_LengthHint(v);
|
n = _PyObject_LengthHint(v);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (!PyErr_ExceptionMatches(PyExc_TypeError) &&
|
if (PyErr_Occurred()
|
||||||
!PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
&& !PyErr_ExceptionMatches(PyExc_TypeError)
|
||||||
|
&& !PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
||||||
Py_DECREF(it);
|
Py_DECREF(it);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -796,8 +796,9 @@ listextend(PyListObject *self, PyObject *b)
|
||||||
/* Guess a result list size. */
|
/* Guess a result list size. */
|
||||||
n = _PyObject_LengthHint(b);
|
n = _PyObject_LengthHint(b);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (!PyErr_ExceptionMatches(PyExc_TypeError) &&
|
if (PyErr_Occurred()
|
||||||
!PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
&& !PyErr_ExceptionMatches(PyExc_TypeError)
|
||||||
|
&& !PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
||||||
Py_DECREF(it);
|
Py_DECREF(it);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue