Author: Philip Jenvey <[email protected]>
Branch: 
Changeset: r68924:263c41db4f9c
Date: 2014-01-24 16:18 -0800
http://bitbucket.org/pypy/pypy/changeset/263c41db4f9c/

Log:    add bytearray.__iter__

diff --git a/pypy/objspace/std/bytearrayobject.py 
b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -285,6 +285,9 @@
             raise
         return space.newbool(res)
 
+    def descr_iter(self, space):
+        return space.newseqiter(self)
+
     def descr_buffer(self, space):
         return BytearrayBuffer(self.data)
 
@@ -893,6 +896,8 @@
     __ge__ = interp2app(W_BytearrayObject.descr_ge,
                         doc=BytearrayDocstrings.__ge__.__doc__),
 
+    __iter__ = interp2app(W_BytearrayObject.descr_iter,
+                         doc=BytearrayDocstrings.__iter__.__doc__),
     __len__ = interp2app(W_BytearrayObject.descr_len,
                          doc=BytearrayDocstrings.__len__.__doc__),
     __contains__ = interp2app(W_BytearrayObject.descr_contains,
diff --git a/pypy/objspace/std/test/test_bytearrayobject.py 
b/pypy/objspace/std/test/test_bytearrayobject.py
--- a/pypy/objspace/std/test/test_bytearrayobject.py
+++ b/pypy/objspace/std/test/test_bytearrayobject.py
@@ -134,6 +134,7 @@
 
     def test_iter(self):
         assert list(bytearray('hello')) == [104, 101, 108, 108, 111]
+        assert list(bytearray('hello').__iter__()) == [104, 101, 108, 108, 111]
 
     def test_compare(self):
         assert bytearray('hello') == bytearray('hello')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to