Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/encoding.py @ 27356:c2effd1ecebf
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.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 12 Dec 2015 23:26:12 -0800 |
parents | b479fc425a81 |
children | c8d3392f76e1 |
comparison
equal
deleted
inserted
replaced
27355:b479fc425a81 | 27356:c2effd1ecebf |
---|---|
405 '' | 405 '' |
406 ''' | 406 ''' |
407 | 407 |
408 if not _jsonmap: | 408 if not _jsonmap: |
409 for x in xrange(32): | 409 for x in xrange(32): |
410 _jsonmap[chr(x)] = "\u%04x" %x | 410 _jsonmap[chr(x)] = "\\u%04x" % x |
411 for x in xrange(32, 256): | 411 for x in xrange(32, 256): |
412 c = chr(x) | 412 c = chr(x) |
413 _jsonmap[c] = c | 413 _jsonmap[c] = c |
414 _jsonmap['\t'] = '\\t' | 414 _jsonmap['\t'] = '\\t' |
415 _jsonmap['\n'] = '\\n' | 415 _jsonmap['\n'] = '\\n' |