# HG changeset patch # User Gregory Szorc # Date 1548525617 28800 # Node ID e82288a9556cee92599a91660eeba1d265e0a270 # Parent 4f0aca2b8c21c43e1eece01a3f5d4a425721536e 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 diff -r 4f0aca2b8c21 -r e82288a9556c mercurial/wireprotov2server.py --- 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'