Amaury Forgeot d'Arc avatar Amaury Forgeot d'Arc committed 290b886 Draft

Fix tuple.__repr__ containing non-ascii strings.

Comments (0)

Files changed (2)

pypy/objspace/std/test/test_tupleobject.py

         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')

pypy/objspace/std/tupleobject.py

     # 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))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.