# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 2017-06-02 05:05:21 # Node ID c032e137e494b36007a877a6049db4c1c184bf16 # Parent 49e1e5acb8ff21f7023f4b47474f74d8c43ad12a py3: convert exception to bytes to pass into ui.warn() Here encoding.strtolocal() is used because exc maybe an IOError which could contain a valid non-ascii unicode. diff --git a/mercurial/hook.py b/mercurial/hook.py --- a/mercurial/hook.py +++ b/mercurial/hook.py @@ -13,6 +13,7 @@ import sys from .i18n import _ from . import ( demandimport, + encoding, error, extensions, pycompat, @@ -97,7 +98,7 @@ def _pythonhook(ui, repo, htype, hname, (hname, exc.args[0])) else: ui.warn(_('error: %s hook raised an exception: ' - '%s\n') % (hname, exc)) + '%s\n') % (hname, encoding.strtolocal(str(exc)))) if throw: raise if not ui.tracebackflag: