[Checkins] SVN: Acquisition/trunk/src/Acquisition/ 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)
Andreas Zeidler
az at zitc.de
Wed Apr 15 10:36:02 EDT 2009
Log message for revision 99191:
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)
Changed:
U Acquisition/trunk/src/Acquisition/_Acquisition.c
U Acquisition/trunk/src/Acquisition/tests.py
-=-
Modified: Acquisition/trunk/src/Acquisition/_Acquisition.c
===================================================================
--- Acquisition/trunk/src/Acquisition/_Acquisition.c 2009-04-15 13:45:10 UTC (rev 99190)
+++ Acquisition/trunk/src/Acquisition/_Acquisition.c 2009-04-15 14:36:02 UTC (rev 99191)
@@ -932,7 +932,7 @@
static PyObject *
Wrapper_iter(Wrapper *self)
{
- return CallMethodO(OBJECT(self), py__iter__, NULL, NULL);
+ return PyObject_GetIter(self->obj);
}
static PySequenceMethods Wrapper_as_sequence = {
Modified: Acquisition/trunk/src/Acquisition/tests.py
===================================================================
--- Acquisition/trunk/src/Acquisition/tests.py 2009-04-15 13:45:10 UTC (rev 99190)
+++ Acquisition/trunk/src/Acquisition/tests.py 2009-04-15 14:36:02 UTC (rev 99191)
@@ -1782,6 +1782,26 @@
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]
+
"""
More information about the Checkins
mailing list