[pypy-commit] pypy py3k: Use unicode when formatting array's repr.

Manuel Jacob noreply at buildbot.pypy.org
Wed Feb 13 22:24:57 CET 2013


Author: Manuel Jacob
Branch: py3k
Changeset: r61197:78f184ffa771
Date: 2013-02-12 16:58 +0100
http://bitbucket.org/pypy/pypy/changeset/78f184ffa771/

Log:	Use unicode when formatting array's repr.

diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -741,7 +741,7 @@
             return space.wrap("array('%s')" % self.typecode)
         elif self.typecode == "u":
             r = space.repr(array_tounicode__Array(space, self))
-            s = "array('%s', %s)" % (self.typecode, space.str_w(r))
+            s = u"array('%s', %s)" % (self.typecode, space.unicode_w(r))
             return space.wrap(s)
         else:
             r = space.repr(array_tolist__Array(space, self))
diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -855,6 +855,12 @@
         assert a == b
         assert self.array('u', bytearray(a.tobytes())) == a
 
+    def test_repr(self):
+        s = '\x00="\'a\\b\x80\xff\u0000\u0001\u1234'
+        a = self.array('u', s)
+        assert repr(a) == "array('u', {!r})".format(s)
+        assert eval(repr(a), {'array': self.array}) == a
+
 
 class DontTestCPythonsOwnArray(BaseArrayTests):
 


More information about the pypy-commit mailing list