[Python-checkins] python/dist/src/Objects listobject.c,2.148,2.149 tupleobject.c,2.78,2.79
rhettinger@users.sourceforge.net
rhettinger@users.sourceforge.net
Thu, 24 Apr 2003 09:52:53 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv13553/Objects
Modified Files:
listobject.c tupleobject.c
Log Message:
SF bug 665835: filter() treatment of str and tuple inconsistent
As a side issue on this bug, it was noted that list and tuple iterators
used macros to directly access containers and would not recognize
__getitem__ overrides. If the method is overridden, the patch returns
a generic sequence iterator which calls the __getitem__ method; otherwise,
it returns a high custom iterator with direct access to container elements.
Index: listobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v
retrieving revision 2.148
retrieving revision 2.149
diff -C2 -d -r2.148 -r2.149
*** listobject.c 14 Apr 2003 20:58:13 -0000 2.148
--- listobject.c 24 Apr 2003 16:52:46 -0000 2.149
***************
*** 2376,2379 ****
--- 2376,2381 ----
return NULL;
}
+ if (seq->ob_type->tp_as_sequence->sq_item != list_item)
+ return PySeqIter_New(seq);
it = PyObject_GC_New(listiterobject, &PyListIter_Type);
if (it == NULL)
Index: tupleobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v
retrieving revision 2.78
retrieving revision 2.79
diff -C2 -d -r2.78 -r2.79
*** tupleobject.c 17 Mar 2003 19:46:11 -0000 2.78
--- tupleobject.c 24 Apr 2003 16:52:47 -0000 2.79
***************
*** 754,757 ****
--- 754,759 ----
return NULL;
}
+ if (seq->ob_type->tp_as_sequence->sq_item != tupleitem)
+ return PySeqIter_New(seq);
it = PyObject_GC_New(tupleiterobject, &PyTupleIter_Type);
if (it == NULL)