[Zope-Checkins] CVS: Zope3/lib/python/Zope/ContextWrapper - test_wrapper.py:1.6.2.9 wrapper.c:1.12.2.10
Fred L. Drake, Jr.
fdrake@acm.org
Mon, 18 Mar 2002 14:49:09 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ContextWrapper
In directory cvs.zope.org:/tmp/cvs-serv15974
Modified Files:
Tag: Zope-3x-branch
test_wrapper.py wrapper.c
Log Message:
Make sure that wrappers around iterable objects support iteration.
They are still not allowed to *be* iterators, but that seems acceptable
for the way these are used.
(A subclass can be an iterator, though.)
=== Zope3/lib/python/Zope/ContextWrapper/test_wrapper.py 1.6.2.8 => 1.6.2.9 ===
self.assert_(callable(w))
+ def test_wrapped_iterable(self):
+ a = [1, 2, 3]
+ b = []
+ for x in wrapper.Wrapper(a):
+ b.append(x)
+ self.assertEquals(a, b)
+
def test_suite():
suite = unittest.TestSuite()
=== Zope3/lib/python/Zope/ContextWrapper/wrapper.c 1.12.2.9 => 1.12.2.10 ===
}
+static PyObject *
+wrap_iter(PyObject *self)
+{
+ return PyObject_GetIter(Wrapper_GetObject(self));
+}
+
static void
wrap_dealloc(PyObject *self)
{
@@ -326,7 +332,7 @@
wrap_clear, /* tp_clear */
wrap_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
- 0, /* tp_iter */
+ wrap_iter, /* tp_iter */
0, /* tp_iternext */
wrap_methods, /* tp_methods */
0, /* tp_members */