comparison 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
comparison
equal deleted inserted replaced
32641:d3e1c5b4986c 32642:d110fb58424c
82 so = '' 82 so = ''
83 if shortopt: 83 if shortopt:
84 so = '-' + shortopt 84 so = '-' + shortopt
85 lo = '--' + longopt 85 lo = '--' + longopt
86 if default: 86 if default:
87 desc += _(" (default: %s)") % default 87 # default is of unknown type, and in Python 2 we abused
88 # the %s-shows-repr property to handle integers etc. To
89 # match that behavior on Python 3, we do str(default) and
90 # then convert it to bytes.
91 desc += _(" (default: %s)") % pycompat.bytestr(default)
88 92
89 if isinstance(default, list): 93 if isinstance(default, list):
90 lo += " %s [+]" % optlabel 94 lo += " %s [+]" % optlabel
91 multioccur = True 95 multioccur = True
92 elif (default is not None) and not isinstance(default, bool): 96 elif (default is not None) and not isinstance(default, bool):