mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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.
This commit is contained in:
parent
3209410cb5
commit
9928571f3f
3 changed files with 16 additions and 0 deletions
|
@ -753,6 +753,8 @@ tuple_iter(PyObject *seq)
|
|||
PyErr_BadInternalCall();
|
||||
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)
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue