diff mercurial/dispatch.py @ 36641:77f98867538f

py3: fix some unicode madness in global exception catcher
author Yuya Nishihara <yuya@tcha.org>
date Sat, 03 Mar 2018 10:02:36 -0500
parents e8c361316803
children 68328202f270
line wrap: on
line diff
--- a/mercurial/dispatch.py	Sat Mar 03 10:08:13 2018 -0500
+++ b/mercurial/dispatch.py	Sat Mar 03 10:02:36 2018 -0500
@@ -496,7 +496,7 @@
             args = pycompat.shlexsplit(self.definition)
         except ValueError as inst:
             self.badalias = (_("error in definition for alias '%s': %s")
-                             % (self.name, inst))
+                             % (self.name, util.forcebytestr(inst)))
             return
         earlyopts, args = _earlysplitopts(args)
         if earlyopts:
@@ -623,7 +623,7 @@
     try:
         args = fancyopts.fancyopts(args, commands.globalopts, options)
     except getopt.GetoptError as inst:
-        raise error.CommandError(None, inst)
+        raise error.CommandError(None, util.forcebytestr(inst))
 
     if args:
         cmd, args = args[0], args[1:]
@@ -647,7 +647,7 @@
     try:
         args = fancyopts.fancyopts(args, c, cmdoptions, gnu=True)
     except getopt.GetoptError as inst:
-        raise error.CommandError(cmd, inst)
+        raise error.CommandError(cmd, util.forcebytestr(inst))
 
     # separate global options back out
     for o in commands.globalopts:
@@ -672,7 +672,8 @@
             configs.append((section, name, value))
         except (IndexError, ValueError):
             raise error.Abort(_('malformed --config option: %r '
-                               '(use --config section.name=value)') % cfg)
+                                '(use --config section.name=value)')
+                              % pycompat.bytestr(cfg))
 
     return configs