aboutsummaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2016-12-20 17:12:21 +0100
committerArmin Rigo <arigo@tunes.org>2016-12-20 17:12:21 +0100
commit3e357a492437a51ca0db5b7d991240b459b9ad6c (patch)
tree41b865b6cf47a7a4967cf6373091aba60a639f5e /py
parentMaybe temporary: change py.test, which displays unicode strings 'xx' (diff)
downloadpypy-3e357a492437a51ca0db5b7d991240b459b9ad6c.tar.gz
pypy-3e357a492437a51ca0db5b7d991240b459b9ad6c.tar.bz2
pypy-3e357a492437a51ca0db5b7d991240b459b9ad6c.zip
Reduce the diff with the original
Diffstat (limited to 'py')
-rw-r--r--py/_io/saferepr.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/py/_io/saferepr.py b/py/_io/saferepr.py
index c988b23f8d..206d3bfe67 100644
--- a/py/_io/saferepr.py
+++ b/py/_io/saferepr.py
@@ -16,11 +16,16 @@ class SafeRepr(reprlib.Repr):
# Strictly speaking wrong on narrow builds
def repr(u):
if "'" not in u:
- return py.builtin._totext("u'%s'") % u
+ return py.builtin._totext("'%s'") % u
elif '"' not in u:
- return py.builtin._totext('u"%s"') % u
+ return py.builtin._totext('"%s"') % u
else:
- return py.builtin._totext("u'%s'") % u.replace("'", r"\'")
+ return py.builtin._totext("'%s'") % u.replace("'", r"\'")
+
+ repr = builtin_repr
+ # ^^^ it's very annoying to display 'xx' instead of u'xx' when
+ # the difference can be essential, particularly in PyPy
+
s = repr(x[:self.maxstring])
if len(s) > self.maxstring:
i = max(0, (self.maxstring-3)//2)