Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 27795:2042e2051d97 legacy-trunk
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.
| author | Walter Dörwald <walter@livinglogic.de> |
|---|---|
| date | Mon, 10 Feb 2003 17:36:40 +0000 |
| parents | b650a54a76fd |
| children | be7683a6f521 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Mon Feb 10 16:08:17 2003 +0000 +++ b/Python/bltinmodule.c Mon Feb 10 17:36:40 2003 +0000 @@ -1888,8 +1888,13 @@ 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;
