New submission from Maurice de Rooij <mau...@gmail.com>: Regular expressions with 0 to 65536 repetitions and above makes Python crash with a "OverflowError: regular expression code size limit exceeded" exception. 65535 repetitions do not raise this issue.
Tested and confirmed this with versions 2.7.1 and 3.2.2. C:\Python27>python.exe Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> re.search('(?s)\A.{0,65535}test', 'test') <_sre.SRE_Match object at 0x00B4E4B8> >>> re.search('(?s)\A.{0,65536}test', 'test') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\re.py", line 142, in search return _compile(pattern, flags).search(string) File "C:\Python27\lib\re.py", line 243, in _compile p = sre_compile.compile(pattern, flags) File "C:\Python27\lib\sre_compile.py", line 523, in compile groupindex, indexgroup OverflowError: regular expression code size limit exceeded >>> C:\Python32>python.exe Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> re.search('(?s)\A.{0,65535}test', 'test') <_sre.SRE_Match object at 0x00A6F250> >>> re.search('(?s)\A.{0,65536}test', 'test') Traceback (most recent call last): File "C:\Python32\lib\functools.py", line 176, in wrapper result = cache[key] KeyError: (<class 'str'>, '(?s)\\A.{0,65536}test', 0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python32\lib\re.py", line 158, in search return _compile(pattern, flags).search(string) File "C:\Python32\lib\re.py", line 255, in _compile return _compile_typed(type(pattern), pattern, flags) File "C:\Python32\lib\functools.py", line 180, in wrapper result = user_function(*args, **kwds) File "C:\Python32\lib\re.py", line 267, in _compile_typed return sre_compile.compile(pattern, flags) File "C:\Python32\lib\sre_compile.py", line 514, in compile groupindex, indexgroup OverflowError: regular expression code size limit exceeded >>> ---------- components: Library (Lib) messages: 145469 nosy: techmaurice priority: normal severity: normal status: open title: Regular expressions with 0 to 65536 repetitions and above makes Python crash type: crash versions: Python 2.7, Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13169> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com