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
bpo-7940: add support for negative end positions to re.finditer and re.findall #14744
base: main
Are you sure you want to change the base?
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
Modules/_sre.c
Outdated
@@ -427,11 +427,15 @@ state_init(SRE_STATE* state, PatternObject* pattern, PyObject* string, | |||
} | |||
|
|||
/* adjust boundaries */ | |||
if (start < 0) | |||
start += length; | |||
if (start < 0) | |||
start = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In re.compile('.').findall("abcd", -10, -3)
, the first if
will set start
to -6
which is not a valid index, and the second if is necessary because it will set it to 0
. There are currently no tests for this scenario, so I would add a couple.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I have made the requested changes; please review again. |
Thanks for making the requested changes! @ezio-melotti: please review the changes made to this pull request. |
I've looked at this again and am still not inclined to accept it. If someone else really believes this is a necessary API expansion and wants to move it forward, I won't object. |
@ezio-melotti should this be merged or should there be further discussion? |
Just rebased at another EuroPython sprint after 3 years :) |
Quick summary
|
This is a breaking change. A FutureWarning should be emitted for 2 releases prior to changing the behavior. |
Hi @serhiy-storchaka is that something to be done in the code of this PR? How can we emit a FutureWarning? |
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
add support for negative end positions to re.finditer and re.findall
https://bugs.python.org/issue7940