Skip to content

Commit 9599352

Browse files
gnpricewebsurfer5
authored andcommitted
bpo-37760: Constant-fold some old options in makeunicodedata. (pythonGH-15129)
The `expand` option was introduced in 2000 in commit fad27ae. It appears to have been always set since it was committed, and what it does is tell the code to do something essential. So, just always do that, and cut the option. Also cut the `linebreakprops` option, which isn't consulted anymore.
1 parent 795dd11 commit 9599352

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

Tools/unicode/makeunicodedata.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -943,10 +943,7 @@ class UnicodeData:
943943
# ISO-comment, uppercase, lowercase, titlecase, ea-width, (16)
944944
# derived-props] (17)
945945

946-
def __init__(self, version,
947-
linebreakprops=False,
948-
expand=1,
949-
cjk_check=True):
946+
def __init__(self, version, cjk_check=True):
950947
self.changed = []
951948
table = [None] * 0x110000
952949
for s in UcdFile(UNICODE_DATA, version):
@@ -956,26 +953,25 @@ def __init__(self, version,
956953
cjk_ranges_found = []
957954

958955
# expand first-last ranges
959-
if expand:
960-
field = None
961-
for i in range(0, 0x110000):
962-
s = table[i]
963-
if s:
964-
if s[1][-6:] == "First>":
965-
s[1] = ""
966-
field = s
967-
elif s[1][-5:] == "Last>":
968-
if s[1].startswith("<CJK Ideograph"):
969-
cjk_ranges_found.append((field[0],
970-
s[0]))
971-
s[1] = ""
972-
field = None
973-
elif field:
974-
f2 = field[:]
975-
f2[0] = "%X" % i
976-
table[i] = f2
977-
if cjk_check and cjk_ranges != cjk_ranges_found:
978-
raise ValueError("CJK ranges deviate: have %r" % cjk_ranges_found)
956+
field = None
957+
for i in range(0, 0x110000):
958+
s = table[i]
959+
if s:
960+
if s[1][-6:] == "First>":
961+
s[1] = ""
962+
field = s
963+
elif s[1][-5:] == "Last>":
964+
if s[1].startswith("<CJK Ideograph"):
965+
cjk_ranges_found.append((field[0],
966+
s[0]))
967+
s[1] = ""
968+
field = None
969+
elif field:
970+
f2 = field[:]
971+
f2[0] = "%X" % i
972+
table[i] = f2
973+
if cjk_check and cjk_ranges != cjk_ranges_found:
974+
raise ValueError("CJK ranges deviate: have %r" % cjk_ranges_found)
979975

980976
# public attributes
981977
self.filename = UNICODE_DATA % ''

0 commit comments

Comments
 (0)