[issue2636] Regexp 2.7 (modifications to current re 2.2.2)

Jacques Grove report at bugs.python.org
Sun Oct 31 06:27:49 CET 2010


Jacques Grove <jacques at tripitinc.com> added the comment:

Here's one that really falls in the category of "don't do that";  but I found this because I was limiting the system recursion level to somewhat less than the standard 1000 (for other reasons), and I had some shorter duplicate patterns in a big regex.  Here is the simplest case to make it blow up with the standard recursion settings:

$ cat test.py
import re, regex
regexp = '(abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ|abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ)'
re.compile(regexp)
regex.compile(regexp)

$ python test.py
<snip big traceback except for last few lines>

File "/tmp/test/src/lib/_regex_core.py", line 2024, in optimise
    subpattern = subpattern.optimise(info)
  File "/tmp/test/src/lib/_regex_core.py", line 1552, in optimise
    branches = [_Branch(branches)]
RuntimeError: maximum recursion depth exceeded

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2636>
_______________________________________


More information about the Python-bugs-list mailing list