Mercurial > hg-stable
changeset 41425:e82288a9556c
wireprotov2server: use our JSON encoder
Python's json module doesn't like to encode bytes instances.
This makes this code difficult to work with Python 3.
We simply swap in Mercurial's JSON encoder to work around it.
Differential Revision: https://phab.mercurial-scm.org/D5712
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 26 Jan 2019 10:00:17 -0800 |
parents | 4f0aca2b8c21 |
children | 43f9b8c0574b |
files | mercurial/wireprotov2server.py |
diffstat | 1 files changed, 3 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/wireprotov2server.py Fri Jan 25 17:11:49 2019 -0800 +++ b/mercurial/wireprotov2server.py Sat Jan 26 10:00:17 2019 -0800 @@ -23,6 +23,7 @@ narrowspec, pycompat, streamclone, + templatefilters, util, wireprotoframing, wireprototypes, @@ -148,8 +149,6 @@ tracker. We then dump the log of all that activity back out to the client. """ - import json - # Reflection APIs have a history of being abused, accidentally disclosing # sensitive data, etc. So we have a config knob. if not ui.configbool('experimental', 'web.api.debugreflect'): @@ -175,12 +174,11 @@ frame.payload)) action, meta = reactor.onframerecv(frame) - states.append(json.dumps((action, meta), sort_keys=True, - separators=(', ', ': '))) + states.append(templatefilters.json((action, meta))) action, meta = reactor.oninputeof() meta['action'] = action - states.append(json.dumps(meta, sort_keys=True, separators=(', ',': '))) + states.append(templatefilters.json(meta)) res.status = b'200 OK' res.headers[b'Content-Type'] = b'text/plain'