mercurial/templatefilters.py
changeset 26860 f9984f76fd90
parent 26843 f580c78ea667
parent 26856 baa77652be68
child 28208 f4418ff2f700
--- 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):