From c56f3acdb0968265be3780f67ef8ea9cf3bd81c7 Mon Sep 17 00:00:00 2001 From: Vyron Vasileiadis Date: Thu, 27 Aug 2026 22:04:33 +0300 Subject: [PATCH] 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. --- Lib/test/test_re.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index ff106c1b341566..616221b9091aff 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -1010,8 +1010,8 @@ def test_property_escapes(self): with self.subTest(char=c): self.assertEqual(bool(ci.fullmatch(c)), expect) self.assertTrue(re.fullmatch(r'\p{Alphabetic=No}+', '123 ')) - # These are engine categories, so (unlike \P of a multi-range - # property) they can be negated inside a character class. + # These are engine categories, so a negated one joins the set directly + # as a CATEGORY rather than being alternated in as a separate branch. self.assertTrue(re.fullmatch(r'[\P{Alphabetic}]+', '123 .')) self.assertTrue(re.fullmatch(r'[\p{XID_Start}_]+', 'foo_bar'))