Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r57788:290b886bc923
Date: 2012-10-04 22:37 +0200
http://bitbucket.org/pypy/pypy/changeset/290b886bc923/

Log:    Fix tuple.__repr__ containing non-ascii strings.

diff --git a/pypy/objspace/std/test/test_tupleobject.py 
b/pypy/objspace/std/test/test_tupleobject.py
--- a/pypy/objspace/std/test/test_tupleobject.py
+++ b/pypy/objspace/std/test/test_tupleobject.py
@@ -330,6 +330,8 @@
         assert repr((1,)) == '(1,)'
         assert repr(()) == '()'
         assert repr((1,2,3)) == '(1, 2, 3)'
+        assert repr(('\xe9',)) == "('\xe9',)"
+        assert repr(('\xe9', 1)) == "('\xe9', 1)"
 
     def test_getslice(self):
         assert ('a', 'b', 'c')[-17: 2] == ('a', 'b')
diff --git a/pypy/objspace/std/tupleobject.py b/pypy/objspace/std/tupleobject.py
--- a/pypy/objspace/std/tupleobject.py
+++ b/pypy/objspace/std/tupleobject.py
@@ -161,10 +161,11 @@
     # XXX this is quite innefficient, still better than calling
     #     it via applevel
     if len(items) == 1:
-        return space.wrap("(" + space.str_w(space.repr(items[0])) + ",)")
-    return space.wrap("(" +
-                 (", ".join([space.str_w(space.repr(item)) for item in items]))
-                      + ")")
+        return space.wrap(u"(" + space.unicode_w(space.repr(items[0])) + u",)")
+    return space.wrap(u"(" +
+                 (u", ".join([space.unicode_w(space.repr(item))
+                              for item in items]))
+                      + u")")
 
 def hash__Tuple(space, w_tuple):
     return space.wrap(hash_tuple(space, w_tuple.wrappeditems))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to