py3: don't crash when re-raising encoding error
authorYuya Nishihara <yuya@tcha.org>
Thu, 01 Mar 2018 17:56:32 -0500
changeset 36549 3696efeab66f
parent 36548 086fc71fbb09
child 36550 7f6be7121b28
py3: don't crash when re-raising encoding error
mercurial/encoding.py
--- a/mercurial/encoding.py	Thu Mar 01 17:43:25 2018 -0500
+++ b/mercurial/encoding.py	Thu Mar 01 17:56:32 2018 -0500
@@ -181,7 +181,8 @@
         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")