Skip to content

Commit 30db44e

Browse files
Apply suggestion from @serhiy-storchaka
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 7ce4add commit 30db44e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Lib/re/_optimizer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def _optimize_charset_segment(charset, iscased=None, fixup=None, fixes=None,
125125
hascased = any(map(iscased, r))
126126
else:
127127
if end > len(charmap):
128-
# Trigger the IndexError growth path below.
128+
if len(charmap) == 0x10000 and start < 0x10000:
129+
charmap[start:0x10000] = b'\x01' * (0x10000 - start)
129130
raise IndexError
130131
charmap[start:end] = b'\x01' * (end - start)
131132
elif op is NEGATE:

0 commit comments

Comments
 (0)