summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2003-02-10 17:36:40 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2003-02-10 17:36:40 (GMT)
commit8dd19321bbb3b4f94d15ca3a405053265b99e91e (patch)
tree8fd34769278798e5b54dfe4f9248cef56f2e3977 /Python
parent8d326b8581e8246d006bd4c5ab1d9f30972ef5cb (diff)
downloadcpython-8dd19321bbb3b4f94d15ca3a405053265b99e91e.zip
cpython-8dd19321bbb3b4f94d15ca3a405053265b99e91e.tar.gz
cpython-8dd19321bbb3b4f94d15ca3a405053265b99e91e.tar.bz2
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.
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index b9aa85c..338e38d 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -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;