changeset 36549:3696efeab66f

py3: don't crash when re-raising encoding error
author Yuya Nishihara <yuya@tcha.org>
date Thu, 01 Mar 2018 17:56:32 -0500
parents 086fc71fbb09
children 7f6be7121b28
files mercurial/encoding.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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")