-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as not planned
Labels
Description
Bug report
Bug description:
Text:
with open('./cpython/Tools/ssl/multissltests.py') as f:
text = f.read()
By doing multiline search on CPython codebase (which works fine):
REG1 = r'''
(\s*)try\:\n
(
(\1)[^\n]*\n
)*
(\1)
else\:\s*if
'''
CMP1 = re.compile(REG1, re.VERBOSE)
CMP1.search(text)
I did one extra addition:
REG2 = r'''
(\s*)try\:\n
(
((\1)[^\n]*)?\n
)*
(\1)
else\:\s*if
'''
CMP2 = re.compile(REG2, re.VERBOSE)
CMP2.search(text) # Hangs indefinitely
I minimised regex so that it still hangs. Although it does not make sense anymore, but it seems to be a minimal example propagating this behaviour:
REG3 = r'([^\n]*)*l'
CMP3 = re.compile(REG3)
CMP3.search(text)
CPython versions tested on:
3.12
Operating systems tested on:
macOS