mirror of https://github.com/python/cpython
Merged revisions 78497 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ 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. ........
This commit is contained in:
parent
b6d80cc893
commit
957c329db0
|
@ -243,22 +243,6 @@ class TestBase:
|
||||||
|
|
||||||
self.assertEqual(ostream.getvalue(), self.tstring[0])
|
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):
|
class TestBase_Mapping(unittest.TestCase):
|
||||||
pass_enctest = []
|
pass_enctest = []
|
||||||
pass_dectest = []
|
pass_dectest = []
|
||||||
|
@ -281,7 +265,8 @@ 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):
|
||||||
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 = {}
|
urt_wa = {}
|
||||||
|
|
||||||
for line in self.open_mapping_file():
|
for line in self.open_mapping_file():
|
||||||
|
@ -306,7 +291,7 @@ class TestBase_Mapping(unittest.TestCase):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
unich = unichrs(data[1])
|
unich = unichrs(data[1])
|
||||||
if ord(unich) == 0xfffd or urt_wa.has_key(unich):
|
if unich == u'\ufffd' or unich in urt_wa:
|
||||||
continue
|
continue
|
||||||
urt_wa[unich] = csetch
|
urt_wa[unich] = csetch
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue