scmutil: avoid using basestring and add explicit handling of unicodes
authorAugie Fackler <augie@google.com>
Sat, 03 Mar 2018 17:08:05 -0500
changeset 36661 b76248e51605
parent 36660 11b279a75bf1
child 36662 3715a5ffcf92
scmutil: avoid using basestring and add explicit handling of unicodes This resolves some Python 3 defects, and I don't think it is a meaningful behavior change in Python 2. Differential Revision: https://phab.mercurial-scm.org/D2611
mercurial/scmutil.py
--- a/mercurial/scmutil.py	Sat Mar 03 17:07:18 2018 -0500
+++ b/mercurial/scmutil.py	Sat Mar 03 17:08:05 2018 -0500
@@ -186,7 +186,10 @@
             ui.warn(_("(%s)\n") % inst.hint)
     except error.ResponseError as inst:
         ui.warn(_("abort: %s") % inst.args[0])
-        if not isinstance(inst.args[1], basestring):
+        msg = inst.args[1]
+        if isinstance(msg, type(u'')):
+            msg = pycompat.sysbytes(msg)
+        elif not isinstance(inst.args[1], bytes):
             ui.warn(" %r\n" % (inst.args[1],))
         elif not inst.args[1]:
             ui.warn(_(" empty string\n"))