Patchwork [08,of,10] py3: don't crash when re-raising encoding error

login
register
mail settings
Submitter Yuya Nishihara
Date March 2, 2018, 12:26 a.m.
Message ID <42239a898f18efa76829.1519950387@mimosa>
Download mbox | patch
Permalink /patch/28632/
State Accepted
Headers show

Comments

Yuya Nishihara - March 2, 2018, 12:26 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1519944992 18000
#      Thu Mar 01 17:56:32 2018 -0500
# Node ID 42239a898f18efa768297ab43b016793726834cd
# Parent  ebad609de255394be78d234e76a61426776e54ae
py3: don't crash when re-raising encoding error

Patch

diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -181,7 +181,8 @@  def fromlocal(s):
         return u.encode("utf-8")
     except UnicodeDecodeError as inst:
         sub = s[max(0, inst.start - 10):inst.start + 10]
-        raise error.Abort("decoding near '%s': %s!" % (sub, inst))
+        raise error.Abort("decoding near '%s': %s!"
+                          % (sub, pycompat.bytestr(inst)))
     except LookupError as k:
         raise error.Abort(k, hint="please check your locale settings")