From 957c329db01786e404187bb3b6b0c948e2689d7a Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Sat, 27 Feb 2010 15:15:10 +0000 Subject: [PATCH] Merged revisions 78497 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ........ r78497 | florent.xicluna | 2010-02-27 16:10:19 +0100 (sam, 27 fév 2010) | 2 lines #7793: Fix RuntimeError when running "regrtest -R" for multibyte codecs. ........ --- Lib/test/test_multibytecodec_support.py | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/Lib/test/test_multibytecodec_support.py b/Lib/test/test_multibytecodec_support.py index feefa9733e6..82e46d66c0e 100644 --- a/Lib/test/test_multibytecodec_support.py +++ b/Lib/test/test_multibytecodec_support.py @@ -243,22 +243,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 = [] @@ -281,7 +265,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(): @@ -306,7 +291,7 @@ class TestBase_Mapping(unittest.TestCase): continue unich = unichrs(data[1]) - if ord(unich) == 0xfffd or urt_wa.has_key(unich): + if unich == u'\ufffd' or unich in urt_wa: continue urt_wa[unich] = csetch