Commit a53801b7 authored by Matti Picus's avatar Matti Picus

backed out changeset 12a7226bdbaa, doesn't work on 2.7

parent 6edb33f857f2
Pipeline #18828 passed with stage
in 7 minutes and 19 seconds
...@@ -279,23 +279,30 @@ class TestBase_Mapping(unittest.TestCase): ...@@ -279,23 +279,30 @@ class TestBase_Mapping(unittest.TestCase):
self._test_mapping_file_plain() self._test_mapping_file_plain()
def _test_mapping_file_plain(self): def _test_mapping_file_plain(self):
def unichrs(s): _unichr = lambda c: eval("u'\\U%08x'" % int(c, 16))
return ''.join(chr(int(x, 16)) for x in s.split('+')) unichrs = lambda s: u''.join(_unichr(c) for c in s.split('+'))
urt_wa = {} urt_wa = {}
with self.open_mapping_file() as f: with self.open_mapping_file() as f:
for line in f: for line in f:
if not line: if not line:
break break
data = line.split('#')[0].split() data = line.split('#')[0].strip().split()
if len(data) != 2: if len(data) != 2:
continue continue
if data[0][:2] != '0x': csetval = eval(data[0])
self.fail("Invalid line: {line!r}".format(line=line)) if csetval <= 0x7F:
csetch = bytes.fromhex(data[0][2:]) csetch = chr(csetval & 0xff)
if len(csetch) == 1 and 0x80 <= csetch[0]: elif csetval >= 0x1000000:
csetch = chr(csetval >> 24) + chr((csetval >> 16) & 0xff) + \
chr((csetval >> 8) & 0xff) + chr(csetval & 0xff)
elif csetval >= 0x10000:
csetch = chr(csetval >> 16) + \
chr((csetval >> 8) & 0xff) + chr(csetval & 0xff)
elif csetval >= 0x100:
csetch = chr(csetval >> 8) + chr(csetval & 0xff)
else:
continue continue
unich = unichrs(data[1]) unich = unichrs(data[1])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment