comparison mercurial/pure/charencode.py @ 34217:5307cc57f271

py3: don't pass bytes to array.array()
author Yuya Nishihara <yuya@tcha.org>
date Sat, 16 Sep 2017 22:42:19 +0900
parents f4433f2713d0
children aa877860d4d7
comparison
equal deleted inserted replaced
34216:1c601df9894c 34217:5307cc57f271
72 if paranoid: 72 if paranoid:
73 jm = _paranoidjsonmap 73 jm = _paranoidjsonmap
74 else: 74 else:
75 jm = _jsonmap 75 jm = _jsonmap
76 # non-BMP char is represented as UTF-16 surrogate pair 76 # non-BMP char is represented as UTF-16 surrogate pair
77 u16codes = array.array('H', u8chars.decode('utf-8').encode('utf-16')) 77 u16codes = array.array(r'H', u8chars.decode('utf-8').encode('utf-16'))
78 u16codes.pop(0) # drop BOM 78 u16codes.pop(0) # drop BOM
79 return ''.join(jm[x] if x < 128 else '\\u%04x' % x for x in u16codes) 79 return ''.join(jm[x] if x < 128 else '\\u%04x' % x for x in u16codes)