ui: convert stack traces to sysbytes before logging
authorAugie Fackler <augie@google.com>
Mon, 12 Feb 2018 20:42:28 -0500
changeset 36127 df1760b58fda
parent 36126 8f5c7f906f9b
child 36128 02ed94dd9fd6
ui: convert stack traces to sysbytes before logging They're coming back as unicodes, so sysbytes seems like the best we can do. This is like D2171 and D2172, but those fail on Python 2.7.5 (seriously!), so this is my version of the same change. I actually wrote this before reviewing those, then discarded it, then came back to it after finding out 2.7.5 is a silly place. Differential Revision: https://phab.mercurial-scm.org/D2209
mercurial/ui.py
--- a/mercurial/ui.py	Mon Feb 12 20:41:47 2018 -0500
+++ b/mercurial/ui.py	Mon Feb 12 20:42:28 2018 -0500
@@ -1620,10 +1620,12 @@
         else:
             curframe = inspect.currentframe()
             calframe = inspect.getouterframes(curframe, 2)
-            self.write_err('%s at: %s:%s (%s)\n'
-                           % ((msg,) + calframe[stacklevel][1:4]))
-            self.log('develwarn', '%s at: %s:%s (%s)\n',
-                     msg, *calframe[stacklevel][1:4])
+            fname, lineno, fmsg = calframe[stacklevel][1:4]
+            fname, fmsg = pycompat.sysbytes(fname), pycompat.sysbytes(fmsg)
+            self.write_err('%s at: %s:%d (%s)\n'
+                           % (msg, fname, lineno, fmsg))
+            self.log('develwarn', '%s at: %s:%d (%s)\n',
+                     msg, fname, lineno, fmsg)
             curframe = calframe = None  # avoid cycles
 
     def deprecwarn(self, msg, version, stacklevel=2):