--- a/mercurial/templatefilters.py Mon Nov 02 12:12:24 2015 -0800
+++ b/mercurial/templatefilters.py Wed Nov 04 15:17:52 2015 -0600
@@ -197,7 +197,11 @@
return {None: 'null', False: 'false', True: 'true'}[obj]
elif isinstance(obj, int) or isinstance(obj, float):
return str(obj)
+ elif isinstance(obj, encoding.localstr):
+ u = encoding.fromlocal(obj).decode('utf-8') # can round-trip
+ return '"%s"' % jsonescape(u)
elif isinstance(obj, str):
+ # no encoding.fromlocal() because it may abort if obj can't be decoded
u = unicode(obj, encoding.encoding, 'replace')
return '"%s"' % jsonescape(u)
elif isinstance(obj, unicode):