D6781: py3: for statprof's Chrome output, write json to string, then encode to bytes

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Sat Aug 31 18:59:21 EDT 2019


Closed by commit rHG06e2467ff27a: py3: for statprof's Chrome output, write json to string, then encode to bytes (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6781?vs=16346&id=16351

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6781/new/

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

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
@@ -875,7 +875,10 @@
               if idx not in blacklist]
     frames = collections.OrderedDict((str(k), v)
                                      for (k,v) in enumerate(id2stack))
-    json.dump(dict(traceEvents=events, stackFrames=frames), fp, indent=1)
+    data = json.dumps(dict(traceEvents=events, stackFrames=frames), indent=1)
+    if not isinstance(data, bytes):
+        data = data.encode('utf-8')
+    fp.write(data)
     fp.write('\n')
 
 def printusage():



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


More information about the Mercurial-devel mailing list