# HG changeset patch
# User Denis Laxalde <de...@laxalde.org>
# Date 1576696641 -3600
#      Wed Dec 18 20:17:21 2019 +0100
# Branch stable
# Node ID 33249635134f8c3fdcd79b1a0da15880a2f57650
# Parent  743c69b393326ab82383638c1fed669794ac0ec1
py3: force bytestr conversion of "reason" in scmutil.callcatch()

For instance, reason may be an InvalidURL as shown in added test.

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
diff --git a/tests/test-clone.t b/tests/test-clone.t
--- a/tests/test-clone.t
+++ b/tests/test-clone.t
@@ -614,6 +614,12 @@ No local source
   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

_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to