py3: encode json output to bytes and use write()
authorGregory Szorc <gregory.szorc@gmail.com>
Fri, 12 Oct 2018 17:25:02 +0200
changeset 40191 4b7eb862692e
parent 40190 31dfa7dac4c9
child 40192 b8f6a99ad89b
py3: encode json output to bytes and use write() Differential Revision: https://phab.mercurial-scm.org/D5007
mercurial/statprof.py
--- a/mercurial/statprof.py	Fri Oct 12 17:48:40 2018 +0000
+++ b/mercurial/statprof.py	Fri Oct 12 17:25:02 2018 +0200
@@ -763,7 +763,11 @@
 
         samples.append((sample.time, stack))
 
-    print(json.dumps(samples), file=fp)
+    data = json.dumps(samples)
+    if not isinstance(data, bytes):
+        data = data.encode('utf-8')
+
+    fp.write(data)
 
 def write_to_chrome(data, fp, minthreshold=0.005, maxthreshold=0.999):
     samples = []