ui: fix ui.traceback on Python 3
authorAugie Fackler <raf@durin42.com>
Fri, 03 Mar 2017 14:09:14 -0500
changeset 31178 81e289ef9376
parent 31177 a7cabac20b62
child 31179 49ad6bf63107
ui: fix ui.traceback on Python 3
mercurial/ui.py
--- a/mercurial/ui.py	Fri Mar 03 14:08:24 2017 -0500
+++ b/mercurial/ui.py	Fri Mar 03 14:09:14 2017 -0500
@@ -1336,7 +1336,11 @@
                                ''.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 = pycompat.sysstr(encoding.encoding)
+                    data = data.encode(enc, errors=r'replace')
+                self.write_err(data)
         return self.tracebackflag or force
 
     def geteditor(self):