diff mercurial/scmutil.py @ 34022:d5b2beca16c0

python3: wrap all uses of <exception>.strerror with strtolocal Our string literals are bytes, and we mostly want to %-format a strerror into a one of those literals, so this fixes a ton of issues.
author Augie Fackler <raf@durin42.com>
date Tue, 22 Aug 2017 20:03:07 -0400
parents 5e83a8fe6bc4
children 9e4f82bc2b0b
line wrap: on
line diff
--- a/mercurial/scmutil.py	Wed Aug 30 14:04:55 2017 -0700
+++ b/mercurial/scmutil.py	Tue Aug 22 20:03:07 2017 -0400
@@ -163,7 +163,8 @@
             ui.warn(_("(lock might be very busy)\n"))
     except error.LockUnavailable as inst:
         ui.warn(_("abort: could not lock %s: %s\n") %
-               (inst.desc or inst.filename, inst.strerror))
+               (inst.desc or inst.filename,
+                encoding.strtolocal(inst.strerror)))
     except error.OutOfBandError as inst:
         if inst.args:
             msg = _("abort: remote error:\n")
@@ -226,16 +227,18 @@
             pass
         elif getattr(inst, "strerror", None):
             if getattr(inst, "filename", None):
-                ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
+                ui.warn(_("abort: %s: %s\n") % (
+                    encoding.strtolocal(inst.strerror), inst.filename))
             else:
-                ui.warn(_("abort: %s\n") % inst.strerror)
+                ui.warn(_("abort: %s\n") % encoding.strtolocal(inst.strerror))
         else:
             raise
     except OSError as inst:
         if getattr(inst, "filename", None) is not None:
-            ui.warn(_("abort: %s: '%s'\n") % (inst.strerror, inst.filename))
+            ui.warn(_("abort: %s: '%s'\n") % (
+                encoding.strtolocal(inst.strerror), inst.filename))
         else:
-            ui.warn(_("abort: %s\n") % inst.strerror)
+            ui.warn(_("abort: %s\n") % encoding.strtolocal(inst.strerror))
     except MemoryError:
         ui.warn(_("abort: out of memory\n"))
     except SystemExit as inst: