summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-02-27 15:10:19 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-02-27 15:10:19 (GMT)
commitbe8c2b1ca7ddbcf50ff59e6a5d63ff9b620d174c (patch)
tree9d988b6ffd859dff2c8d7cfa4de72e9a89d29436
parent37212ed489991665d911e32ca68b1a35d4b3624d (diff)
downloadcpython-be8c2b1ca7ddbcf50ff59e6a5d63ff9b620d174c.zip
cpython-be8c2b1ca7ddbcf50ff59e6a5d63ff9b620d174c.tar.gz
cpython-be8c2b1ca7ddbcf50ff59e6a5d63ff9b620d174c.tar.bz2
#7793: Fix RuntimeError when running "regrtest -R" for multibyte codecs.
-rw-r--r--Lib/test/test_multibytecodec_support.py21
1 files changed, 3 insertions, 18 deletions
diff --git a/Lib/test/test_multibytecodec_support.py b/Lib/test/test_multibytecodec_support.py
index 36245b7..9aa764a 100644
--- a/Lib/test/test_multibytecodec_support.py
+++ b/Lib/test/test_multibytecodec_support.py
@@ -244,22 +244,6 @@ class TestBase:
self.assertEqual(ostream.getvalue(), self.tstring[0])
-if len(u'\U00012345') == 2: # ucs2 build
- _unichr = unichr
- def unichr(v):
- if v >= 0x10000:
- return _unichr(0xd800 + ((v - 0x10000) >> 10)) + \
- _unichr(0xdc00 + ((v - 0x10000) & 0x3ff))
- else:
- return _unichr(v)
- _ord = ord
- def ord(c):
- if len(c) == 2:
- return 0x10000 + ((_ord(c[0]) - 0xd800) << 10) + \
- (ord(c[1]) - 0xdc00)
- else:
- return _ord(c)
-
class TestBase_Mapping(unittest.TestCase):
pass_enctest = []
pass_dectest = []
@@ -282,7 +266,8 @@ class TestBase_Mapping(unittest.TestCase):
self._test_mapping_file_plain()
def _test_mapping_file_plain(self):
- unichrs = lambda s: u''.join(map(unichr, map(eval, s.split('+'))))
+ _unichr = lambda c: eval("u'\\U%08x'" % int(c, 16))
+ unichrs = lambda s: u''.join(_unichr(c) for c in s.split('+'))
urt_wa = {}
for line in self.open_mapping_file():
@@ -307,7 +292,7 @@ class TestBase_Mapping(unittest.TestCase):
continue
unich = unichrs(data[1])
- if ord(unich) == 0xfffd or unich in urt_wa:
+ if unich == u'\ufffd' or unich in urt_wa:
continue
urt_wa[unich] = csetch