encoding: use double backslash
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 12 Dec 2015 23:26:12 -0800
changeset 27356 c2effd1ecebf
parent 27355 b479fc425a81
child 27357 7f5a0bd4c9aa
encoding: use double backslash In Python 2, '\u' == '\\u'. However, in Python 3, '\u' results in: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \uXXXX escape The minor change in this patch allows Python 3 to ast parse encoding.py.
mercurial/encoding.py
--- a/mercurial/encoding.py	Sat Dec 12 22:57:48 2015 -0500
+++ b/mercurial/encoding.py	Sat Dec 12 23:26:12 2015 -0800
@@ -407,7 +407,7 @@
 
     if not _jsonmap:
         for x in xrange(32):
-            _jsonmap[chr(x)] = "\u%04x" %x
+            _jsonmap[chr(x)] = "\\u%04x" % x
         for x in xrange(32, 256):
             c = chr(x)
             _jsonmap[c] = c