GeezerVison is showing github.com — gh-95555: Fix a stale comment about negating \P in a character class by fedonman · Pull Request #156490 · python/cpython
Conversation
fedonman
commented
Aug 27, 2026
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
The comment above the [\P{Alphabetic}] assertion in test_property_escapes still says that, unlike an engine category, \P of a multi-range property cannot be negated inside a character class. GH-152245 lifted that restriction, and the same test now asserts fifty lines below that [\P{ASCII}], [\P{ASCII}abc] and [^\P{ASCII}] all match. The comment now states the distinction that does remain, which is how the member is compiled rather than whether it is allowed:
>>> re._parser.parse(r'[\P{Alphabetic}x]')
[(IN, [(CATEGORY, CATEGORY_NOT_ALPHA), (LITERAL, 120)])]
>>> re._parser.parse(r'[\P{ASCII}x]')
[(BRANCH, (None, [[(LITERAL, 120)], [(IN, [(NEGATE, None), (RANGE, (0, 127))])]]))]
test_property_escapes (test.test_re.ReTests.test_property_escapes) ... ok
Total tests: run=1 (filtered)
Result: SUCCESS
Comment-only change in a test file, so there is no news entry.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…class
pythonGH-152245 lifted the restriction that a negated multi-range property
could not appear inside a character class, and added assertions in
test_property_escapes showing that [\P{ASCII}] and friends now match.
It left in place an earlier comment in the same test saying that,
unlike an engine category, \P of a multi-range property cannot be
negated inside a character class.
The distinction that remains is how the member is compiled, not
whether it is allowed: an engine category joins the set directly as a
CATEGORY, while a multi-range \P is alternated in as a separate branch.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|