[pypy-commit] pypy py3k-fix-strategies: fix BytesStrategy iter to wrapbytes
pjenvey
noreply at buildbot.pypy.org
Fri Apr 18 20:14:17 CEST 2014
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k-fix-strategies
Changeset: r70760:724161bbeca1
Date: 2014-04-18 11:13 -0700
http://bitbucket.org/pypy/pypy/changeset/724161bbeca1/
Log: fix BytesStrategy iter to wrapbytes
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -1439,7 +1439,7 @@
def next_entry(self):
for key in self.iterator:
- return self.space.wrap(key)
+ return self.space.wrapbytes(key)
else:
return None
diff --git a/pypy/objspace/std/test/test_setobject.py b/pypy/objspace/std/test/test_setobject.py
--- a/pypy/objspace/std/test/test_setobject.py
+++ b/pypy/objspace/std/test/test_setobject.py
@@ -89,6 +89,7 @@
from pypy.objspace.std.floatobject import W_FloatObject
w = self.space.wrap
+ wb = self.space.wrapbytes
intstr = self.space.fromcache(IntegerSetStrategy)
tmp_func = intstr.get_storage_from_list
# test if get_storage_from_list is no longer used
@@ -100,10 +101,10 @@
assert w_set.strategy is intstr
assert intstr.unerase(w_set.sstorage) == {1:None, 2:None, 3:None}
- w_list = W_ListObject(self.space, [w("1"), w("2"), w("3")])
+ w_list = W_ListObject(self.space, [wb("1"), wb("2"), wb("3")])
w_set = W_SetObject(self.space)
_initialize_set(self.space, w_set, w_list)
- assert w_set.strategy is self.space.fromcache(UnicodeSetStrategy)
+ assert w_set.strategy is self.space.fromcache(BytesSetStrategy)
assert w_set.strategy.unerase(w_set.sstorage) == {"1":None, "2":None, "3":None}
w_list = self.space.iter(W_ListObject(self.space, [w(u"1"), w(u"2"), w(u"3")]))
@@ -1005,6 +1006,13 @@
# gives us 1, but 1 is not in the set any longer.
raises(RuntimeError, list, it)
+ def test_iter_bytes_strategy(self):
+ l = [b'a', b'b']
+ s = set(l)
+ n = next(iter(s))
+ assert type(n) is bytes
+ assert n in l
+
def test_unicodestrategy(self):
s = 'àèìòù'
myset = set([s])
More information about the pypy-commit
mailing list