# HG changeset patch # User Gregory Szorc # Date 2018-10-12 15:25:02 # Node ID 4b7eb862692eb29b7997780ff1e78877e0cd839c # Parent 31dfa7dac4c94f7a5de7580958c70b1391afe446 py3: encode json output to bytes and use write() Differential Revision: https://phab.mercurial-scm.org/D5007 diff --git a/mercurial/statprof.py b/mercurial/statprof.py --- a/mercurial/statprof.py +++ b/mercurial/statprof.py @@ -763,7 +763,11 @@ def write_to_json(data, fp): 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 = []