[pypy-commit] pypy py3k: bah, of course we need to call unicode_w in the unicode set strategy

antocuni noreply at buildbot.pypy.org
Wed Oct 10 17:04:52 CEST 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r57975:ba0a57363695
Date: 2012-10-10 16:53 +0200
http://bitbucket.org/pypy/pypy/changeset/ba0a57363695/

Log:	bah, of course we need to call unicode_w in the unicode set strategy

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
@@ -695,7 +695,7 @@
         return True
 
     def unwrap(self, w_item):
-        return self.space.str_w(w_item)
+        return self.space.unicode_w(w_item)
 
     def wrap(self, item):
         return self.space.wrap(item)
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
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
 """
 The main test for the set implementation is located
 in the stdlibs test/test_set.py which is located in lib-python
@@ -961,3 +962,17 @@
         # getting a RuntimeError because iterating over the old storage
         # gives us 1, but 1 is not in the set any longer.
         raises(RuntimeError, list, it)
+
+    def test_unicodestrategy(self):
+        s = 'àèìòù'
+        myset = {s}
+        s2 = myset.pop()
+        assert s2 == s
+
+    def test_preserve_identity_of_strings(self):
+        s = 'hello'
+        myset = {s}
+        s2 = myset.pop()
+        assert s2 == s
+        assert s2 is s
+        


More information about the pypy-commit mailing list