changeset 37941:af83a0ed0afb

stringutil: make pprint() forward uninteresting object to b'%r' We appear to start using pprint() as a replacement for repr(), so it's probably safer to support any Python objects instead of complaining about that.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 10 May 2018 21:00:58 +0900
parents 31c37e703cee
children 32bc3815efae
files mercurial/utils/stringutil.py
diffstat 1 files changed, 1 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/utils/stringutil.py	Fri Apr 27 13:46:54 2018 -0400
+++ b/mercurial/utils/stringutil.py	Thu May 10 21:00:58 2018 +0900
@@ -40,18 +40,10 @@
             '%s: %s' % (pprint(k, bprefix=bprefix),
                         pprint(v, bprefix=bprefix))
             for k, v in sorted(o.items())))
-    elif isinstance(o, bool):
-        return b'True' if o else b'False'
-    elif isinstance(o, int):
-        return '%d' % o
-    elif isinstance(o, float):
-        return '%f' % o
     elif isinstance(o, tuple):
         return '(%s)' % (b', '.join(pprint(a, bprefix=bprefix) for a in o))
-    elif o is None:
-        return b'None'
     else:
-        raise error.ProgrammingError('do not know how to format %r' % o)
+        return pycompat.byterepr(o)
 
 def binary(s):
     """return true if a string is binary data"""