This revision was automatically updated to reflect the committed changes.
Closed by commit rHG68132a95df31: stringutil: support more types with pprint() 
(authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3302?vs=8103&id=8109

REVISION DETAIL
  https://phab.mercurial-scm.org/D3302

AFFECTED FILES
  mercurial/utils/stringutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/stringutil.py b/mercurial/utils/stringutil.py
--- a/mercurial/utils/stringutil.py
+++ b/mercurial/utils/stringutil.py
@@ -25,15 +25,23 @@
 
 def pprint(o):
     """Pretty print an object."""
-    if isinstance(o, (bytes, bytearray)):
+    if isinstance(o, bytes):
         return "b'%s'" % escapestr(o)
+    elif isinstance(o, bytearray):
+        # codecs.escape_encode() can't handle bytearray, so escapestr fails
+        # without coercion.
+        return "bytearray['%s']" % escapestr(bytes(o))
     elif isinstance(o, list):
         return '[%s]' % (b', '.join(pprint(a) for a in o))
     elif isinstance(o, dict):
         return '{%s}' % (b', '.join(
             '%s: %s' % (pprint(k), pprint(v)) 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
     else:
         raise error.ProgrammingError('do not know how to format %r' % o)
 



To: indygreg, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to