[Python-checkins] r78497 - python/trunk/Lib/test/test_multibytecodec_support.py

florent.xicluna python-checkins at python.org
Sat Feb 27 16:10:19 CET 2010


Author: florent.xicluna
Date: Sat Feb 27 16:10:19 2010
New Revision: 78497
Log:
#7793: Fix RuntimeError when running "regrtest -R" for multibyte codecs.
Modified:
 python/trunk/Lib/test/test_multibytecodec_support.py
Modified: python/trunk/Lib/test/test_multibytecodec_support.py
==============================================================================
--- python/trunk/Lib/test/test_multibytecodec_support.py	(original)
+++ python/trunk/Lib/test/test_multibytecodec_support.py	Sat Feb 27 16:10:19 2010
@@ -244,22 +244,6 @@
 
 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 @@
 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 @@
 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
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /