comparison mercurial/hook.py @ 32665:c032e137e494

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.
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 02 Jun 2017 10:35:21 +0530
parents 4b426ae96ff2
children 799db2af824c
comparison
equal deleted inserted replaced
32664:49e1e5acb8ff 32665:c032e137e494
11 import sys 11 import sys
12 12
13 from .i18n import _ 13 from .i18n import _
14 from . import ( 14 from . import (
15 demandimport, 15 demandimport,
16 encoding,
16 error, 17 error,
17 extensions, 18 extensions,
18 pycompat, 19 pycompat,
19 util, 20 util,
20 ) 21 )
95 if isinstance(exc, error.Abort): 96 if isinstance(exc, error.Abort):
96 ui.warn(_('error: %s hook failed: %s\n') % 97 ui.warn(_('error: %s hook failed: %s\n') %
97 (hname, exc.args[0])) 98 (hname, exc.args[0]))
98 else: 99 else:
99 ui.warn(_('error: %s hook raised an exception: ' 100 ui.warn(_('error: %s hook raised an exception: '
100 '%s\n') % (hname, exc)) 101 '%s\n') % (hname, encoding.strtolocal(str(exc))))
101 if throw: 102 if throw:
102 raise 103 raise
103 if not ui.tracebackflag: 104 if not ui.tracebackflag:
104 ui.warn(_('(run with --traceback for stack trace)\n')) 105 ui.warn(_('(run with --traceback for stack trace)\n'))
105 ui.traceback() 106 ui.traceback()