Commits

Armin Rigo  committed b6b8831

issue #1628: fix iter(iter(array.array()))

  • Participants
  • Parent commits 13f682c
  • Branches py3k

Comments (0)

Files changed (2)

File pypy/module/array/interp_array.py

     def __init__(self, array):
         self.index = 0
         self.array = array
+
+    def iter_w(self, space):
+        return space.wrap(self)
         
     def next_w(self, space):
         if self.index < self.array.len:
 
 ArrayIterator.typedef = TypeDef(
     'arrayiterator',
+    __iter__ = interp2app(ArrayIterator.iter_w),
     __next__ = interp2app(ArrayIterator.next_w),
     )
 

File pypy/module/array/test/test_array.py

             b = array_reconstructor(
                 array.array, 'u', mformat_code, teststr.encode(encoding))
             assert a == b
+
+    def test_iterate_iterator(self):
+        import array
+        it = iter(array.array('b'))
+        assert list(it) == []
+        assert list(iter(it)) == []