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.
diff --git a/src/gen-os2-unicode-ranges.py b/src/gen-os2-unicode-ranges.py
index d768313..8cf5985 100644
--- a/src/gen-os2-unicode-ranges.py
+++ b/src/gen-os2-unicode-ranges.py
@@ -10,8 +10,11 @@
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 @@
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)