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
SRE bugs with capturing groups in negative assertions #38345
Comments
SRE is broken in some subtle ways when you combine >>> re.match('((?!(a)c)[ab])*', 'abc').groups()
('b', '') In the above '(a)' has matched an empty string. Or >>> re.match('(a)((?!(b)*))*', 'abb').groups()
('b', None, None) Here '(a)' matches 'b'. Although Perl reports matches for groups in negative >>> re.match('(a)c|ab', 'ab').groups()
(None,) In the above, although '(a)' matches before the branch Anyway, the attached patch is an effort to fix this |
Logged In: YES In thinking further, I realized that positive assertions are also >>> re.match('(a)(?:(?=(b)*)c)*', 'abb').groups()
('b', None) The problem here is that a successful match in an assertion |
Logged In: YES Greg, I think there are two different issues here. One of them is related to a wrong behavior from
And was applied as: Modules/_sre.c: 2.95 The other issue is related to the asserts which are leaving Thank you very much for spotting these bugs, and submitting |
Logged In: YES Gustavo, Just a quick note on compatibility. As I mentioned, the PCRE >>> pre.match('((?!(a)c)[ab])*', 'abc').groups()
('b', None) Although I understand your argument, I'll just say that I Thanks for reviewing my patches and fixing the bugs! |
looks to have been fixed. |
I need help to resolve this problem caused when program a scheduled task Traceback (most recent call last):
File "ftp_eme.py", line 12, in ?
import datetime, os, ftplib
File "/usr/local/lib/python2.6/ftplib.py", line 46, in ?
import socket
File "/usr/local/lib/python2.6/socket.py", line 50, in ?
import _ssl
File "/usr/local/lib/python2.6/_ssl.py", line 58, in ?
import textwrap
File "/usr/local/lib/python2.6/textwrap.py", line 10, in ?
import string, re
File "/usr/local/lib/python2.6/string.py", line 81, in ?
import re as _re
File "/usr/local/lib/python2.6/re.py", line 105, in ?
import sre_compile
File "/usr/local/lib/python2.6/sre_compile.py", line 17, in ?
assert _sre.MAGIC == MAGIC, "SRE module mismatch"
AssertionError: SRE module mismatch
No message, no subject; hope that's ok |
Please do not hijack existing issues. In the case of this problem, do |
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: