# HG changeset patch # User Martin von Zweigbergk # Date 1567204247 25200 # Node ID cd3b5be5515dacde9ee8eb2f523c4e7161e27325 # Parent db6d7cbda80bcc81a8f512f9eb46bcd1c0dc6cde py3: for statprof's Chrome output, write json to string, then encode to bytes `json.dump(obj, fp)` requires `fp.write()` to accept str output, and since the file pointer we have there only accepts bytes, we need to change to json.dumps() and then encode as utf-8. We have already done the same thing for the json (non-Chrome) format in 4b7eb862692e (py3: encode json output to bytes and use write(), 2018-10-12). Differential Revision: https://phab.mercurial-scm.org/D6781 diff -r db6d7cbda80b -r cd3b5be5515d mercurial/statprof.py --- a/mercurial/statprof.py Fri Aug 30 16:44:31 2019 -0700 +++ b/mercurial/statprof.py Fri Aug 30 15:30:47 2019 -0700 @@ -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():