# HG changeset patch # User Yuya Nishihara # Date 1492922418 -32400 # Node ID 08d0892c93d811868771369e42fdaffad5d2e4a2 # Parent 8f83f924ee1c20b0c4ecd9e7f456c0f2181b25fa json: avoid extra string manipulation of dict keys A key must be string per JSON spec, and that's also true for template dicts. diff -r 8f83f924ee1c -r 08d0892c93d8 mercurial/templatefilters.py --- a/mercurial/templatefilters.py Fri Jun 09 21:45:22 2017 +0900 +++ b/mercurial/templatefilters.py Sun Apr 23 13:40:18 2017 +0900 @@ -234,7 +234,7 @@ elif isinstance(obj, bytes): return '"%s"' % encoding.jsonescape(obj, paranoid=paranoid) elif util.safehasattr(obj, 'keys'): - out = ['%s: %s' % (json(k), json(v)) + out = ['"%s": %s' % (encoding.jsonescape(k, paranoid=paranoid), json(v)) for k, v in sorted(obj.iteritems())] return '{' + ', '.join(out) + '}' elif util.safehasattr(obj, '__iter__'):