[issue33566] re.findall() dead locked whent the expected ending char not occur until end of string

Tim Peters report at bugs.python.org
Fri May 18 13:56:58 EDT 2018


Tim Peters <tim at python.org> added the comment:

Min, you need to give a complete example other people can actually run for themselves.

Offhand, this part of the regexp

(.|\s)*

all by itself _can_ cause exponential-time behavior. You can run this for yourself:

>>> import re
>>> p = r"(.|\s)*K"
>>> re.search(p, " " * 10) # fast
>>> re.search(p, " " * 15) # fast
>>> re.search(p, " " * 20) # obviously takes a bit of time
>>> re.search(p, " " * 21) # very obviously takes time
>>> re.search(p, " " * 22) # over a second
>>> re.search(p, " " * 25) # about 10 seconds

Etc.

----------
nosy: +tim.peters

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33566>
_______________________________________


More information about the Python-bugs-list mailing list