py3: force bytestr conversion of "reason" in scmutil.callcatch() stable 5.2.2
authorDenis Laxalde <denis@laxalde.org>
Wed, 18 Dec 2019 20:17:21 +0100
branchstable
changeset 43947 b4c82b704180
parent 43868 b06cf2809ec3
child 43998 453c4f07de0f
py3: force bytestr conversion of "reason" in scmutil.callcatch() For instance, reason may be an InvalidURL as shown in added test.
mercurial/scmutil.py
tests/test-clone.t
--- a/mercurial/scmutil.py	Tue Nov 19 23:19:57 2019 +0900
+++ b/mercurial/scmutil.py	Wed Dec 18 20:17:21 2019 +0100
@@ -262,7 +262,7 @@
             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
--- a/tests/test-clone.t	Tue Nov 19 23:19:57 2019 +0900
+++ b/tests/test-clone.t	Wed Dec 18 20:17:21 2019 +0100
@@ -614,6 +614,12 @@
   abort: repository a not found!
   [255]
 
+Invalid URL
+
+  $ hg clone http://invalid:url/a b
+  abort: error: nonnumeric port: 'url'
+  [255]
+
 No remote source
 
 #if windows