Skip to content

Commit c56f3ac

Browse files
committed
gh-95555: Fix a stale comment about negating \P in a character class
GH-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.
1 parent 45e5b1b commit c56f3ac

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/test/test_re.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,8 +1010,8 @@ def test_property_escapes(self):
10101010
with self.subTest(char=c):
10111011
self.assertEqual(bool(ci.fullmatch(c)), expect)
10121012
self.assertTrue(re.fullmatch(r'\p{Alphabetic=No}+', '123 '))
1013-
# These are engine categories, so (unlike \P of a multi-range
1014-
# property) they can be negated inside a character class.
1013+
# These are engine categories, so a negated one joins the set directly
1014+
# as a CATEGORY rather than being alternated in as a separate branch.
10151015
self.assertTrue(re.fullmatch(r'[\P{Alphabetic}]+', '123 .'))
10161016
self.assertTrue(re.fullmatch(r'[\p{XID_Start}_]+', 'foo_bar'))
10171017

0 commit comments

Comments
 (0)