This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author techmaurice
Recipients techmaurice
Date 2011-10-13.16:30:26
SpamBayes Score 9.103829e-15
Marked as misclassified No
Message-id <1318523427.81.0.476768111228.issue13169@psf.upfronthosting.co.za>
In-reply-to
Content
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
>>>
History
Date User Action Args
2011-10-13 16:30:27techmauricesetrecipients: + techmaurice
2011-10-13 16:30:27techmauricesetmessageid: <1318523427.81.0.476768111228.issue13169@psf.upfronthosting.co.za>
2011-10-13 16:30:27techmauricelinkissue13169 messages
2011-10-13 16:30:26techmauricecreate