# HG changeset patch # User Gregory Szorc # Date 1539357902 -7200 # Node ID 4b7eb862692eb29b7997780ff1e78877e0cd839c # Parent 31dfa7dac4c94f7a5de7580958c70b1391afe446 py3: encode json output to bytes and use write() Differential Revision: https://phab.mercurial-scm.org/D5007 diff -r 31dfa7dac4c9 -r 4b7eb862692e 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 = []