[Python-checkins] r78498 - in python/branches/release26-maint: Lib/test/test_multibytecodec_support.py

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


Author: florent.xicluna
Date: Sat Feb 27 16:15:10 2010
New Revision: 78498

Log:
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.
........


Modified:
   python/branches/release26-maint/   (props changed)
   python/branches/release26-maint/Lib/test/test_multibytecodec_support.py

Modified: python/branches/release26-maint/Lib/test/test_multibytecodec_support.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_multibytecodec_support.py	(original)
+++ python/branches/release26-maint/Lib/test/test_multibytecodec_support.py	Sat Feb 27 16:15:10 2010
@@ -243,22 +243,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 = []
@@ -281,7 +265,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():
@@ -306,7 +291,7 @@
                 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
 


More information about the Python-checkins mailing list