Python 3 fixes to gen-os2-unicode-ranges.py (#1521)
In Python 3, __reload()__ was moved and __sys.setdefaultencoding()__ because the default is already utf-8. Also __Error()__ is an _undefined name_ and __Exception()__ creates a generic exception.
This commit is contained in:
parent
e5989e0962
commit
f4da28b1f1
|
@ -10,8 +10,11 @@ import io
|
|||
import re
|
||||
import sys
|
||||
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf-8')
|
||||
try:
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf-8')
|
||||
except NameError:
|
||||
pass # Python 3
|
||||
|
||||
print ("""static OS2Range _hb_os2_unicode_ranges[] =
|
||||
{""")
|
||||
|
@ -32,12 +35,12 @@ with io.open(input_file, mode="r", encoding="utf-8") as f:
|
|||
current_bit = fields[0]
|
||||
fields = fields[1:]
|
||||
elif len(fields) > 3:
|
||||
raise Error("bad input :(.")
|
||||
raise Exception("bad input :(.")
|
||||
|
||||
name = fields[0]
|
||||
ranges = re.split("-", fields[1])
|
||||
if len(ranges) != 2:
|
||||
raise Error("bad input :(.")
|
||||
raise Exception("bad input :(.")
|
||||
|
||||
v = tuple((int(ranges[0], 16), int(ranges[1], 16), int(current_bit), name))
|
||||
all_ranges.append(v)
|
||||
|
|
Loading…
Reference in New Issue