D5007: py3: encode json output to bytes and use write()

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Fri Oct 12 17:02:04 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4b7eb862692e: py3: encode json output to bytes and use write() (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5007?vs=11920&id=11944

REVISION DETAIL
  https://phab.mercurial-scm.org/D5007

AFFECTED FILES
  mercurial/statprof.py

CHANGE DETAILS

diff --git a/mercurial/statprof.py b/mercurial/statprof.py
--- a/mercurial/statprof.py
+++ b/mercurial/statprof.py
@@ -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 = []



To: indygreg, #hg-reviewers, pulkit
Cc: mercurial-devel


More information about the Mercurial-devel mailing list