changeset 32619:d110fb58424c

help: convert flag default to bytes portably We were relying on %s using repr on (for example) integer values. Work around that for Python 3 while preserving all the prior magic.
author Augie Fackler <raf@durin42.com>
date Sun, 28 May 2017 15:49:29 -0400
parents d3e1c5b4986c
children 3ce53a499334
files mercurial/help.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/help.py	Thu Jun 01 23:08:23 2017 +0900
+++ b/mercurial/help.py	Sun May 28 15:49:29 2017 -0400
@@ -84,7 +84,11 @@
             so = '-' + shortopt
         lo = '--' + longopt
         if default:
-            desc += _(" (default: %s)") % default
+            # default is of unknown type, and in Python 2 we abused
+            # the %s-shows-repr property to handle integers etc. To
+            # match that behavior on Python 3, we do str(default) and
+            # then convert it to bytes.
+            desc += _(" (default: %s)") % pycompat.bytestr(default)
 
         if isinstance(default, list):
             lo += " %s [+]" % optlabel