-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-91760: More strict rules for numerical group references and group names in RE #91792
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8909d14
gh-91760: More strict rules for numerical group references and group …
serhiy-storchaka 46f320d
Merge branch 'main' into re-group-name
serhiy-storchaka 6c1a446
Merge branch 'main' into re-group-name
serhiy-storchaka 5026649
Address review comments and minimize the diff.
serhiy-storchaka 2f486af
Merge branch 'main' into re-group-name
serhiy-storchaka ed09039
Merge branch 'main' into re-group-name
serhiy-storchaka 954ef45
Merge branch 're-group-name' of github.com:serhiy-storchaka/cpython i…
serhiy-storchaka 3835c24
Merge branch 'main' into re-group-name
serhiy-storchaka e0d2f85
Merge branch 'main' into re-group-name
serhiy-storchaka 3c0dfcc
Update What's New
serhiy-storchaka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -395,7 +395,8 @@ The special characters are: | |
``(?P<name>...)`` | ||
Similar to regular parentheses, but the substring matched by the group is | ||
accessible via the symbolic group name *name*. Group names must be valid | ||
Python identifiers, and each group name must be defined only once within a | ||
Python identifiers, and in bytes patterns they must contain only characters | ||
in the ASCII range. Each group name must be defined only once within a | ||
regular expression. A symbolic group is also a numbered group, just as if | ||
the group were not named. | ||
|
||
|
@@ -417,6 +418,10 @@ The special characters are: | |
| | * ``\1`` | | ||
+---------------------------------------+----------------------------------+ | ||
|
||
.. versionchanged:: 3.11 | ||
In bytes patterns group names must contain only characters in | ||
the ASCII range. | ||
|
||
.. index:: single: (?P=; in regular expressions | ||
|
||
``(?P=name)`` | ||
|
@@ -486,6 +491,9 @@ The special characters are: | |
will match with ``'<[email protected]>'`` as well as ``'[email protected]'``, but | ||
not with ``'<[email protected]'`` nor ``'[email protected]>'``. | ||
|
||
.. versionchanged:: 3.11 | ||
Group *id* can only contain ASCII digits and cannot start with ``0``. | ||
|
||
|
||
The special sequences consist of ``'\'`` and a character from the list below. | ||
If the ordinary character is not an ASCII digit or an ASCII letter, then the | ||
|
@@ -995,6 +1003,12 @@ form. | |
Empty matches for the pattern are replaced when adjacent to a previous | ||
non-empty match. | ||
|
||
.. versionchanged:: 3.11 | ||
Group *id* can only contain ASCII digits and cannot start with ``0`` | ||
(except group 0). | ||
In bytes replacement strings group names must contain only characters | ||
in the ASCII range. | ||
|
||
|
||
.. function:: subn(pattern, repl, string, count=0, flags=0) | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
Misc/NEWS.d/next/Library/2022-04-21-19-14-29.gh-issue-91760.54AR-m.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Apply more strict rules for numerical group references and group names in | ||
regular expressions. 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. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.