-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
bpo-7940: add support for negative end positions to re.finditer and re.findall #14744
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
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! |
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.
LGTM
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? |
a749312
to
a7b0605
Compare
Just rebased at another EuroPython sprint after 3 years :) |
Quick summary
|
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.
Re-approving the overall PR, but we need a regex expert on this @ezio-melotti @serhiy-storchaka
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? |
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.
See #14744 (comment)
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 |
73147f2
to
b3dfb5a
Compare
@serhiy-storchaka @iritkatriel I have made the requested changes; please review again. :) |
Thanks for making the requested changes! @iritkatriel, @ezio-melotti, @isidentical: please review the changes made to this pull request. |
@isidentical since your last review I only added the FutureWarnings. |
Future Warning is emitted in #107105 |
Maybe it would be worth having global macro for this? |
Hi @dg-pb, Thank you for your reply. This PR has been open for about 5 years now. Are you a core developer, and would you be interested in seeing this change merged? |
I am not. Just decided to go through old PRs and decided to offer my thoughts for this one. Hopefully someone familiar with |
add support for negative end positions to re.finditer and re.findall
https://bugs.python.org/issue7940