[pypy-commit] pypy py3k: __iter__ all the things
pjenvey
noreply at buildbot.pypy.org
Sat Jan 25 02:34:05 CET 2014
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r68932:dbf9786cc7d8
Date: 2014-01-24 17:33 -0800
http://bitbucket.org/pypy/pypy/changeset/dbf9786cc7d8/
Log: __iter__ all the things
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
@@ -233,9 +233,6 @@
raise
return space.newbool(res)
- def descr_iter(self, space):
- return space.newseqiter(self)
-
def descr_buffer(self, space):
return BytearrayBuffer(self.data)
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -56,6 +56,9 @@
def descr_hash(self, space):
"""x.__hash__() <==> hash(x)"""
+ def descr_iter(self, space):
+ """x.__iter__() <==> iter(x)"""
+
def descr_le(self, space, w_other):
"""x.__le__(y) <==> x<=y"""
@@ -787,6 +790,7 @@
__gt__ = interpindirect2app(W_AbstractBytesObject.descr_gt),
__ge__ = interpindirect2app(W_AbstractBytesObject.descr_ge),
+ __iter__ = interpindirect2app(W_AbstractBytesObject.descr_iter),
__len__ = interpindirect2app(W_AbstractBytesObject.descr_len),
__contains__ = interpindirect2app(W_AbstractBytesObject.descr_contains),
diff --git a/pypy/objspace/std/stringmethods.py b/pypy/objspace/std/stringmethods.py
--- a/pypy/objspace/std/stringmethods.py
+++ b/pypy/objspace/std/stringmethods.py
@@ -57,8 +57,8 @@
def descr_len(self, space):
return space.wrap(self._len())
- #def descr_iter(self, space):
- # pass
+ def descr_iter(self, space):
+ return space.newseqiter(self)
def descr_contains(self, space, w_sub):
value = self._val(space)
diff --git a/pypy/objspace/std/test/test_bytesobject.py b/pypy/objspace/std/test/test_bytesobject.py
--- a/pypy/objspace/std/test/test_bytesobject.py
+++ b/pypy/objspace/std/test/test_bytesobject.py
@@ -652,6 +652,7 @@
for i in iter(b"42"):
l.append(i)
assert l == [52, 50]
+ assert list(b"42".__iter__()) == [52, 50]
def test_repr(self):
for f in str, repr:
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -336,9 +336,6 @@
return newformat.run_formatter(space, w_format_spec, "format_string",
self)
- def descr_iter(self, space):
- return space.newseqiter(self)
-
def descr_mod(self, space, w_values):
return mod_format(space, self, w_values, do_unicode=True)
More information about the pypy-commit
mailing list