[PATCH 5 of 6 py3] ui: fix ui.traceback on Python 3

Yuya Nishihara yuya at tcha.org
Sun Mar 5 01:35:31 EST 2017


On Fri, 03 Mar 2017 14:30:08 -0500, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <raf at durin42.com>
> # Date 1488568154 18000
> #      Fri Mar 03 14:09:14 2017 -0500
> # Node ID 168a2acc512f0dbcc9d1469ae97ea4226fc18243
> # Parent  224bce12f19ec6fb7ab1563797d81e902121dcb6
> ui: fix ui.traceback on Python 3
> 
> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -1335,7 +1335,9 @@ class ui(object):
>                                 ''.join(exconly))
>              else:
>                  output = traceback.format_exception(exc[0], exc[1], exc[2])
> -                self.write_err(''.join(output))
> +                data = u''.join(output).encode(

output may contain non-ascii bytes on Python 2, which causes
UnicodeDecodeError.

> +                    encoding.encoding.decode('latin1'))

And this could raise UnicodeEncodeError on Python 3. The easiest workaround
would be setting errors='replace'.


More information about the Mercurial-devel mailing list