Skip to content
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

gh-91760: More strict rules for numerical group references and group names in RE #91792

Merged
merged 10 commits into from May 8, 2022

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Apr 21, 2022

Only sequence of ASCII digits not starting with 0 (except group 0) is
now accepted as a numerical reference.
The group name in bytes patterns and replacement strings can now only
contain ASCII letters and digits and underscore.

Closes #91760.

…group names in RE

Only sequence of ASCII digits not starting with 0 (except group 0) is
now accepted as a numerical reference.
The group name in bytes patterns and replacement strings can now only
contain ASCII letters and digits and underscore.
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Apr 21, 2022
…id in future

Only sequence of ASCII digits not starting with 0 (except group 0) will be
accepted as a numerical reference.
The group name in bytes patterns and replacement strings could only
contain ASCII letters and digits and underscore.
Copy link
Member

@ezio-melotti ezio-melotti left a comment

I'm also not sure about forbidding the leading 0, since it feels like a special case that only makes things more complicated and inconsistent with other implementations.

Doc/whatsnew/3.11.rst Outdated Show resolved Hide resolved
Lib/re/_parser.py Show resolved Hide resolved
Lib/re/_parser.py Show resolved Hide resolved
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Apr 24, 2022

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Copy link
Member Author

@serhiy-storchaka serhiy-storchaka left a comment

This PR adds restrictions without deprecation. See also #91794.

Lib/re/_parser.py Show resolved Hide resolved
Lib/re/_parser.py Show resolved Hide resolved
@serhiy-storchaka
Copy link
Member Author

@serhiy-storchaka serhiy-storchaka commented Apr 24, 2022

I have made the requested changes; please review again.

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Apr 24, 2022

Thanks for making the requested changes!

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

@bedevere-bot bedevere-bot requested a review from ezio-melotti Apr 24, 2022
Copy link
Member

@ezio-melotti ezio-melotti left a comment

LGTM. Are you still planning to add a deprecation warning?

@serhiy-storchaka
Copy link
Member Author

@serhiy-storchaka serhiy-storchaka commented Apr 24, 2022

See #91794.

@serhiy-storchaka serhiy-storchaka marked this pull request as draft Apr 30, 2022
@serhiy-storchaka serhiy-storchaka added the type-feature label Apr 30, 2022
Doc/whatsnew/3.11.rst Outdated Show resolved Hide resolved
@serhiy-storchaka serhiy-storchaka marked this pull request as ready for review May 8, 2022
@serhiy-storchaka serhiy-storchaka merged commit a84a56d into python:main May 8, 2022
13 checks passed
@serhiy-storchaka serhiy-storchaka deleted the re-group-name branch May 8, 2022
@ooliver1
Copy link

@ooliver1 ooliver1 commented May 8, 2022

What's that DO-NOT-MERGE label for

@serhiy-storchaka
Copy link
Member Author

@serhiy-storchaka serhiy-storchaka commented May 9, 2022

Oh, I forget to remove it.

It meant that the PR should not be merged by accident in 3.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expert-regex type-feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants