changeset 40191:4b7eb862692e

py3: encode json output to bytes and use write() Differential Revision: https://phab.mercurial-scm.org/D5007
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 12 Oct 2018 17:25:02 +0200
parents 31dfa7dac4c9
children b8f6a99ad89b
files mercurial/statprof.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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 = []