From patchwork Mon May 29 14:32:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [01,of,10,py3] help: convert flag default to bytes portably From: Augie Fackler X-Patchwork-Id: 21046 Message-Id: <75e176c753d2c2c7eb5b.1496068343@imladris.local> To: mercurial-devel@mercurial-scm.org Date: Mon, 29 May 2017 10:32:23 -0400 # HG changeset patch # User Augie Fackler # Date 1496000969 14400 # Sun May 28 15:49:29 2017 -0400 # Node ID 75e176c753d2c2c7eb5b5c0791bc993160fcb7b1 # Parent aa333c1982abfe12a3940811d07468a286de93db 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. diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -84,7 +84,11 @@ def optrst(header, options, verbose): 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.sysbytes(str(default)) if isinstance(default, list): lo += " %s [+]" % optlabel