Blame SOURCES/00355-CVE-2020-27619.patch

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