File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -279,30 +279,23 @@ def test_mapping_file(self):
279279 self ._test_mapping_file_plain ()
280280
281281 def _test_mapping_file_plain (self ):
282- _unichr = lambda c : eval ("u'\\ U%08x'" % int (c , 16 ))
283- unichrs = lambda s : u'' .join (_unichr (c ) for c in s .split ('+' ))
282+ def unichrs (s ):
283+ return '' .join (unichr (int (x , 16 )) for x in s .split ('+' ))
284+
284285 urt_wa = {}
285286
286287 with self .open_mapping_file () as f :
287288 for line in f :
288289 if not line :
289290 break
290- data = line .split ('#' )[0 ].strip (). split ()
291+ data = line .split ('#' )[0 ].split ()
291292 if len (data ) != 2 :
292293 continue
293294
294- csetval = eval (data [0 ])
295- if csetval <= 0x7F :
296- csetch = chr (csetval & 0xff )
297- elif csetval >= 0x1000000 :
298- csetch = chr (csetval >> 24 ) + chr ((csetval >> 16 ) & 0xff ) + \
299- chr ((csetval >> 8 ) & 0xff ) + chr (csetval & 0xff )
300- elif csetval >= 0x10000 :
301- csetch = chr (csetval >> 16 ) + \
302- chr ((csetval >> 8 ) & 0xff ) + chr (csetval & 0xff )
303- elif csetval >= 0x100 :
304- csetch = chr (csetval >> 8 ) + chr (csetval & 0xff )
305- else :
295+ if len (data [0 ]) < 3 or data [0 ][:2 ] != '0x' :
296+ self .fail ("Invalid line: {line!r}" .format (line = line ))
297+ csetch = data [0 ][2 :].decode ('hex' )
298+ if 0x80 <= ord (csetch [0 ]):
306299 continue
307300
308301 unich = unichrs (data [1 ])
You can’t perform that action at this time.
0 commit comments