Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
anilbey wants to merge5 commits intopython:main
base:main
Choose a base branch
Loading
fromanilbey:bpo7940

Conversation

anilbey
Copy link
Contributor

@anilbeyanilbey commentedJul 13, 2019
edited by bedevere-bot
Loading

add support for negative end positions to re.finditer and re.findall

https://bugs.python.org/issue7940

@the-knights-who-say-ni

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 thePSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username onbugs.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 followthe steps outlined in the CPython devguide to rectify this issue.

You cancheck yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

Copy link
Member

@isidenticalisidentical left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM

@@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Inre.compile('.').findall("abcd", -10, -3), the firstif will setstart to-6 which is not a valid index, and the second if is necessary because it will set it to0. There are currently no tests for this scenario, so I would add a couple.

@bedevere-bot
Copy link

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 phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@rhettingerrhettinger self-assigned thisJul 13, 2019
@anilbey
Copy link
ContributorAuthor

I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@ezio-melotti: please review the changes made to this pull request.

@rhettinger
Copy link
Contributor

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.

@csabella
Copy link
Contributor

@ezio-melotti should this be merged or should there be further discussion?

anilbey reacted with thumbs up emoji

@anilbey
Copy link
ContributorAuthor

Just rebased at another EuroPython sprint after 3 years :)

@anilbey
Copy link
ContributorAuthor

Quick summary

  • the current implementation accepts negative indices but silently truncates them to 0, which I doubt is the expected behaviour
  • this change allows negative indices to be used the same way they work in other collections
  • it enables consistency with the regex module
  • however it introduces a behavioural change

Copy link
Member

@isidenticalisidentical left a 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

@serhiy-storchaka
Copy link
Member

This is a breaking change. A FutureWarning should be emitted for 2 releases prior to changing the behavior.

@anilbey
Copy link
ContributorAuthor

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?

Copy link
Member

@iritkatrieliritkatriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@bedevere-bot
Copy link

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 phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@anilbeyanilbeyforce-pushed thebpo7940 branch 3 times, most recently from73147f2 tob3dfb5aCompareMarch 15, 2023 10:00
@anilbey
Copy link
ContributorAuthor

@serhiy-storchaka@iritkatriel I have made the requested changes; please review again. :)

@bedevere-bot
Copy link

Thanks for making the requested changes!

@iritkatriel,@ezio-melotti,@isidentical: please review the changes made to this pull request.

@anilbey
Copy link
ContributorAuthor

@isidentical since your last review I only added the FutureWarnings.

@anilbey
Copy link
ContributorAuthor

anilbey commentedAug 16, 2023
edited
Loading

Future Warning is emitted in#107105

@dg-pb
Copy link
Contributor

Maybe it would be worth having global macro for this?
There is one inunicodeobject.c:ADJUST_INDICES, one inbytes_methods.c:ADJUST_INDICES and the same is done here. The same could be used when dealing with sequence indices too.

@anilbey
Copy link
ContributorAuthor

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?

@dg-pb
Copy link
Contributor

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 withre can resolve whether to close or implement this.

anilbey reacted with thumbs up emoji

@pythonpython deleted a commentApr 7, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ezio-melottiezio-melottiAwaiting requested review from ezio-melotti

@iritkatrieliritkatrielAwaiting requested review from iritkatriel

@isidenticalisidenticalAwaiting requested review from isidentical

Assignees

@ezio-melottiezio-melotti

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

11 participants
@anilbey@the-knights-who-say-ni@bedevere-bot@rhettinger@csabella@serhiy-storchaka@dg-pb@iritkatriel@ezio-melotti@isidentical@AlexWaygood

[8]ページ先頭

©2009-2025 Movatter.jp