[pypy-commit] pypy py3k: Fix %r formatting when given a string with printable character: the result is not ascii...
amauryfa
noreply at buildbot.pypy.org
Sat Oct 20 23:30:19 CEST 2012
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r58284:0a29fdad36f4
Date: 2012-10-20 23:10 +0200
http://bitbucket.org/pypy/pypy/changeset/0a29fdad36f4/
Log: Fix %r formatting when given a string with printable character: the
result is not ascii...
diff --git a/pypy/objspace/std/formatting.py b/pypy/objspace/std/formatting.py
--- a/pypy/objspace/std/formatting.py
+++ b/pypy/objspace/std/formatting.py
@@ -447,7 +447,7 @@
self.std_wp(s)
def fmt_r(self, w_value):
- self.std_wp(self.space.str_w(self.space.repr(w_value)))
+ self.std_wp(self.space.unicode_w(self.space.repr(w_value)))
def fmt_c(self, w_value):
self.prec = -1 # just because
diff --git a/pypy/objspace/std/test/test_unicodeobject.py b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -839,6 +839,10 @@
return '\u1234'
'%s' % X()
+ def test_formatting_unicode__repr__(self):
+ # Printable character
+ assert '%r' % chr(0xe9) == "'\xe9'"
+
def test_str_subclass(self):
class Foo9(str):
def __str__(self):
More information about the pypy-commit
mailing list