New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
re.match raises MemoryError #56386
Labels
Comments
re.match raises MemoryError when trying to match r'()+?1' to 'a1', as shown below. ~$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.match(r'()+?1', 'a1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/re.py", line 137, in match
return _compile(pattern, flags).match(string)
MemoryError
>>>
~$ python3
Python 3.2 (r32:88445, Mar 25 2011, 19:28:28)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.match(r'()+?1', 'a1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.2/re.py", line 153, in match
return _compile(pattern, flags).match(string)
MemoryError
>>> |
Confirmed. The test case quickly uses 8GB of memory. |
This also raises MemoryError:
but none of these do:
|
This also raises in 2.6.5 Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.match('()+?1', 'a1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/re.py", line 137, in match
return _compile(pattern, flags).match(string)
MemoryError |
Here are some windows results with Python 2.7: >>> import re
>>> re.match("()*?1", "1")
<_sre.SRE_Match object at 0x025C0E60>
>>> re.match("()+?1", "1")
>>> re.match("()+?1", "11")
<_sre.SRE_Match object at 0x025C0E60>
>>> re.match("()*?1", "11")
<_sre.SRE_Match object at 0x025C3C60>
<_sre.SRE_Match object at 0x025C3C60>
>>> re.match("()*?1", "a1")
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
re.match("()*?1", "a1")
File "C:\Python27\lib\re.py", line 137, in match
return _compile(pattern, flags).match(string)
MemoryError
>>> re.match("()+?1", "a1")
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
re.match("()+?1", "a1")
File "C:\Python27\lib\re.py", line 137, in match
return _compile(pattern, flags).match(string)
MemoryError Note that when matching to a string starting with "1", the matcher will not throw a MemoryError. |
This is a duplicate of bpo-9669. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: