mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Merged revisions 85503 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85503 | antoine.pitrou | 2010-10-15 00:11:44 +0200 (ven., 15 oct. 2010) | 2 lines More proper closing of files ........
This commit is contained in:
parent
80800d3571
commit
99d848bd4b
7 changed files with 81 additions and 60 deletions
|
@ -252,7 +252,7 @@ class TestBase_Mapping(unittest.TestCase):
|
|||
def __init__(self, *args, **kw):
|
||||
unittest.TestCase.__init__(self, *args, **kw)
|
||||
try:
|
||||
self.open_mapping_file() # test it to report the error early
|
||||
self.open_mapping_file().close() # test it to report the error early
|
||||
except (IOError, HTTPException):
|
||||
self.skipTest("Could not retrieve "+self.mapfileurl)
|
||||
|
||||
|
@ -270,36 +270,38 @@ class TestBase_Mapping(unittest.TestCase):
|
|||
unichrs = lambda s: u''.join(_unichr(c) for c in s.split('+'))
|
||||
urt_wa = {}
|
||||
|
||||
for line in self.open_mapping_file():
|
||||
if not line:
|
||||
break
|
||||
data = line.split('#')[0].strip().split()
|
||||
if len(data) != 2:
|
||||
continue
|
||||
with self.open_mapping_file() as f:
|
||||
for line in f:
|
||||
if not line:
|
||||
break
|
||||
data = line.split('#')[0].strip().split()
|
||||
if len(data) != 2:
|
||||
continue
|
||||
|
||||
csetval = eval(data[0])
|
||||
if csetval <= 0x7F:
|
||||
csetch = chr(csetval & 0xff)
|
||||
elif csetval >= 0x1000000:
|
||||
csetch = chr(csetval >> 24) + chr((csetval >> 16) & 0xff) + \
|
||||
chr((csetval >> 8) & 0xff) + chr(csetval & 0xff)
|
||||
elif csetval >= 0x10000:
|
||||
csetch = chr(csetval >> 16) + \
|
||||
chr((csetval >> 8) & 0xff) + chr(csetval & 0xff)
|
||||
elif csetval >= 0x100:
|
||||
csetch = chr(csetval >> 8) + chr(csetval & 0xff)
|
||||
else:
|
||||
continue
|
||||
csetval = eval(data[0])
|
||||
if csetval <= 0x7F:
|
||||
csetch = chr(csetval & 0xff)
|
||||
elif csetval >= 0x1000000:
|
||||
csetch = chr(csetval >> 24) + chr((csetval >> 16) & 0xff) + \
|
||||
chr((csetval >> 8) & 0xff) + chr(csetval & 0xff)
|
||||
elif csetval >= 0x10000:
|
||||
csetch = chr(csetval >> 16) + \
|
||||
chr((csetval >> 8) & 0xff) + chr(csetval & 0xff)
|
||||
elif csetval >= 0x100:
|
||||
csetch = chr(csetval >> 8) + chr(csetval & 0xff)
|
||||
else:
|
||||
continue
|
||||
|
||||
unich = unichrs(data[1])
|
||||
if unich == u'\ufffd' or unich in urt_wa:
|
||||
continue
|
||||
urt_wa[unich] = csetch
|
||||
unich = unichrs(data[1])
|
||||
if unich == u'\ufffd' or unich in urt_wa:
|
||||
continue
|
||||
urt_wa[unich] = csetch
|
||||
|
||||
self._testpoint(csetch, unich)
|
||||
self._testpoint(csetch, unich)
|
||||
|
||||
def _test_mapping_file_ucm(self):
|
||||
ucmdata = self.open_mapping_file().read()
|
||||
with self.open_mapping_file() as f:
|
||||
ucmdata = f.read()
|
||||
uc = re.findall('<a u="([A-F0-9]{4})" b="([0-9A-F ]+)"/>', ucmdata)
|
||||
for uni, coded in uc:
|
||||
unich = unichr(int(uni, 16))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue