Skip to content

Commit 56e25cd

Browse files
committed
review comment
1 parent e7ca3ef commit 56e25cd

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Lib/re/_compiler.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ def _optimize_charset(charset, iscased=None, fixup=None, fixes=None):
266266
else:
267267
charmap[av] = 1
268268
elif op is RANGE:
269-
r = range(av[0], av[1]+1)
269+
start, end = av
270+
end += 1
271+
r = range(start, end)
270272
if fixup: # IGNORECASE and not LOCALE
271273
if fixes:
272274
for i in map(fixup, r):
@@ -280,11 +282,10 @@ def _optimize_charset(charset, iscased=None, fixup=None, fixes=None):
280282
if not hascased:
281283
hascased = any(map(iscased, r))
282284
else:
283-
end = av[1] + 1
284285
if end > len(charmap):
285286
# Trigger the IndexError growth path below.
286287
raise IndexError
287-
charmap[av[0]:end] = b'\x01' * (end - av[0])
288+
charmap[start:end] = b'\x01' * (end - start)
288289
elif op is NEGATE:
289290
out.append((op, av))
290291
elif op is CATEGORY and tail and (CATEGORY, CH_NEGATE[av]) in tail:

0 commit comments

Comments
 (0)