[PATCH STABLE] py3: force bytestr conversion of "reason" in scmutil.callcatch()

Denis Laxalde denis at laxalde.org
Wed Dec 18 11:45:09 EST 2019


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1576687426 -3600
#      Wed Dec 18 17:43:46 2019 +0100
# Branch stable
# Node ID b5ea9c258bedfc2ba12111e98c038076ded3ac6a
# Parent  b06cf2809ec3486b25187ac2c8e766d6ac18763b
py3: force bytestr conversion of "reason" in scmutil.callcatch()

For instance, reason may be InvalidURL.

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -262,7 +262,7 @@ def callcatch(ui, func):
             if isinstance(reason, pycompat.unicode):
                 # SSLError of Python 2.7.9 contains a unicode
                 reason = encoding.unitolocal(reason)
-            ui.error(_(b"abort: error: %s\n") % reason)
+            ui.error(_(b"abort: error: %s\n") % stringutil.forcebytestr(reason))
         elif (
             util.safehasattr(inst, b"args")
             and inst.args


More information about the Mercurial-devel mailing list