changeset 40195:720355c7b7c9

py3: use sysbytes for converting code attributes Differential Revision: https://phab.mercurial-scm.org/D5012
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 12 Oct 2018 18:30:40 +0200
parents 1ae0faa14797
children 2864f8d3fcd6
files mercurial/lsprofcalltree.py
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/lsprofcalltree.py	Fri Oct 12 18:26:10 2018 +0200
+++ b/mercurial/lsprofcalltree.py	Fri Oct 12 18:30:40 2018 +0200
@@ -12,12 +12,17 @@
 
 from __future__ import absolute_import
 
+from . import (
+    pycompat,
+)
+
 def label(code):
     if isinstance(code, str):
-        return '~' + code    # built-in functions ('~' sorts at the end)
+        # built-in functions ('~' sorts at the end)
+        return '~' + pycompat.sysbytes(code)
     else:
-        return '%s %s:%d' % (code.co_name,
-                             code.co_filename,
+        return '%s %s:%d' % (pycompat.sysbytes(code.co_name),
+                             pycompat.sysbytes(code.co_filename),
                              code.co_firstlineno)
 
 class KCacheGrind(object):
@@ -46,7 +51,7 @@
         if isinstance(code, str):
             out_file.write(b'fi=~\n')
         else:
-            out_file.write(b'fi=%s\n' % code.co_filename)
+            out_file.write(b'fi=%s\n' % pycompat.sysbytes(code.co_filename))
 
         out_file.write(b'fn=%s\n' % label(code))
 
@@ -80,7 +85,7 @@
             out_file.write(b'cfi=~\n')
             out_file.write(b'calls=%d 0\n' % subentry.callcount)
         else:
-            out_file.write(b'cfi=%s\n' % code.co_filename)
+            out_file.write(b'cfi=%s\n' % pycompat.sysbytes(code.co_filename))
             out_file.write(b'calls=%d %d\n' % (
                 subentry.callcount, code.co_firstlineno))