merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError

This commit is contained in:
Christian Heimes 2007-12-05 12:51:23 +00:00
parent c8dbc92395
commit 03acd85dbf
3 changed files with 9 additions and 4 deletions

View File

@ -12,6 +12,9 @@ What's New in Python 2.5.2c1?
Core and builtins Core and builtins
----------------- -----------------
- Issue #1553: An errornous __length_hint__ can make list() raise a
SystemError.
- Issue #1521: On 64bit platforms, using PyArgs_ParseTuple with the t# of w# - Issue #1521: On 64bit platforms, using PyArgs_ParseTuple with the t# of w#
format code incorrectly truncated the length to an int, even when format code incorrectly truncated the length to an int, even when
PY_SSIZE_T_CLEAN is set. The str.decode method used to return incorrect PY_SSIZE_T_CLEAN is set. The str.decode method used to return incorrect

View File

@ -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;
} }

View File

@ -784,8 +784,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;
} }