Mercurial > hg-stable
diff mercurial/help.py @ 32642: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 | c9318beb7c1a |
children | 0407a51b9d8c |
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