mirror of
https://github.com/python/cpython.git
synced 2025-10-21 06:02:21 +00:00
Change filtertuple() to use tp_as_sequence->sq_item
instead of PyTuple_GetItem, so an overwritten __getitem__ in a tuple subclass works. SF bug #665835.
This commit is contained in:
parent
8d326b8581
commit
8dd19321bb
2 changed files with 7 additions and 3 deletions
|
@ -1888,8 +1888,13 @@ filtertuple(PyObject *func, PyObject *tuple)
|
|||
PyObject *item, *good;
|
||||
int ok;
|
||||
|
||||
if ((item = PyTuple_GetItem(tuple, i)) == NULL)
|
||||
if (tuple->ob_type->tp_as_sequence &&
|
||||
tuple->ob_type->tp_as_sequence->sq_item) {
|
||||
item = tuple->ob_type->tp_as_sequence->sq_item(tuple, i);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError, "unsubscriptable object");
|
||||
goto Fail_1;
|
||||
}
|
||||
if (func == Py_None) {
|
||||
Py_INCREF(item);
|
||||
good = item;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue