|
|
71f264 |
diff --git a/Lib/test/multibytecodec_support.py b/Lib/test/multibytecodec_support.py
|
|
|
71f264 |
index f9884c6..98feec2 100644
|
|
|
71f264 |
--- a/Lib/test/multibytecodec_support.py
|
|
|
71f264 |
+++ b/Lib/test/multibytecodec_support.py
|
|
|
71f264 |
@@ -300,29 +300,23 @@ class TestBase_Mapping(unittest.TestCase):
|
|
|
71f264 |
self._test_mapping_file_plain()
|
|
|
71f264 |
|
|
|
71f264 |
def _test_mapping_file_plain(self):
|
|
|
71f264 |
- unichrs = lambda s: ''.join(map(chr, map(eval, s.split('+'))))
|
|
|
71f264 |
+ def unichrs(s):
|
|
|
71f264 |
+ return ''.join(chr(int(x, 16)) for x in s.split('+'))
|
|
|
71f264 |
+
|
|
|
71f264 |
urt_wa = {}
|
|
|
71f264 |
|
|
|
71f264 |
with self.open_mapping_file() as f:
|
|
|
71f264 |
for line in f:
|
|
|
71f264 |
if not line:
|
|
|
71f264 |
break
|
|
|
71f264 |
- data = line.split('#')[0].strip().split()
|
|
|
71f264 |
+ data = line.split('#')[0].split()
|
|
|
71f264 |
if len(data) != 2:
|
|
|
71f264 |
continue
|
|
|
71f264 |
|
|
|
71f264 |
- csetval = eval(data[0])
|
|
|
71f264 |
- if csetval <= 0x7F:
|
|
|
71f264 |
- csetch = bytes([csetval & 0xff])
|
|
|
71f264 |
- elif csetval >= 0x1000000:
|
|
|
71f264 |
- csetch = bytes([(csetval >> 24), ((csetval >> 16) & 0xff),
|
|
|
71f264 |
- ((csetval >> 8) & 0xff), (csetval & 0xff)])
|
|
|
71f264 |
- elif csetval >= 0x10000:
|
|
|
71f264 |
- csetch = bytes([(csetval >> 16), ((csetval >> 8) & 0xff),
|
|
|
71f264 |
- (csetval & 0xff)])
|
|
|
71f264 |
- elif csetval >= 0x100:
|
|
|
71f264 |
- csetch = bytes([(csetval >> 8), (csetval & 0xff)])
|
|
|
71f264 |
- else:
|
|
|
71f264 |
+ if data[0][:2] != '0x':
|
|
|
71f264 |
+ self.fail(f"Invalid line: {line!r}")
|
|
|
71f264 |
+ csetch = bytes.fromhex(data[0][2:])
|
|
|
71f264 |
+ if len(csetch) == 1 and 0x80 <= csetch[0]:
|
|
|
71f264 |
continue
|
|
|
71f264 |
|
|
|
71f264 |
unich = unichrs(data[1])
|