Commit 683054c1 authored by Andreas Zeidler's avatar Andreas Zeidler

update for r94905: the proxy for `__iter__` must not rely on the object to...

update for r94905: the proxy for `__iter__` must not rely on the object to have an `__iter__` itself, but also support fall-back iteration via `__getitem__` (this fixes https://bugs.launchpad.net/zope2/+bug/360761)
parent 34202a5f
......@@ -932,7 +932,7 @@ Wrapper_contains(Wrapper *self, PyObject *v)
static PyObject *
Wrapper_iter(Wrapper *self)
{
return CallMethodO(OBJECT(self), py__iter__, NULL, NULL);
return PyObject_GetIter(self->obj);
}
static PySequenceMethods Wrapper_as_sequence = {
......
......@@ -1782,6 +1782,26 @@ def test_proxying():
iterating...
[42]
Finally let's check that https://bugs.launchpad.net/zope2/+bug/360761
has been fixed:
>>> class C(Acquisition.Implicit):
... l=[1,2,3]
... def __getitem__(self, i):
... return self.l[i]
>>> c1 = C()
>>> type(iter(c1))
<type 'iterator'>
>>> list(c1)
[1, 2, 3]
>>> c2 = C().__of__(c1)
>>> type(iter(c2))
<type 'iterator'>
>>> list(c2)
[1, 2, 3]
"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment