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

Augie Fackler raf at durin42.com
Mon Mar 6 18:23:07 EST 2017


# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1488568154 18000
#      Fri Mar 03 14:09:14 2017 -0500
# Node ID cf5be2a3d1804666dff9a4c99a33354dab7cc322
# Parent  2e19b1921f0ba7f3550c11f7f3c85e88e732e3a0
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
@@ -1336,7 +1336,11 @@ class ui(object):
                                ''.join(exconly))
             else:
                 output = traceback.format_exception(exc[0], exc[1], exc[2])
-                self.write_err(''.join(output))
+                data = r''.join(output)
+                if pycompat.ispy3:
+                  enc = encoding.encoding.decode('latin1', errors='replace')
+                  data = data.encode(enc, errors='replace')
+                self.write_err(data)
         return self.tracebackflag or force
 
     def geteditor(self):


More information about the Mercurial-devel mailing list