Skip to content

gh-156185: Ignore all ASCII whitespace in re \p{} property names - #156304

Open
Georgefifth wants to merge 1 commit into
python:mainfrom
Georgefifth:fix/re-property-whitespace
Open

gh-156185: Ignore all ASCII whitespace in re \p{} property names#156304
Georgefifth wants to merge 1 commit into
python:mainfrom
Georgefifth:fix/re-property-whitespace

Conversation

@Georgefifth

@Georgefifth Georgefifth commented Aug 24, 2026

Copy link
Copy Markdown

Problem
The docs (and the _normalize comment) promise that \p{...} property and value names are matched loosely — case, whitespace, hyphens and underscores are not significant (UAX #44, LM3). In practice only spaces were removed, so \p{L\tu} or \p{G\nC=Lu} raised re.error: unknown property "L\ntu" while the space form worked. (3.16-only feature, so no compatibility concern.)

Solution
_normalize() in Lib/re/_properties.py now drops all ASCII whitespace ( \t\n\r\f\v), not just space; comment updated to match.

Result
Added a regression loop over all six whitespace characters in test_re.py::test_property_escapes; full test_re passes (169 tests) on a debug build, and the new assertions fail on the unpatched code. NEWS entry added.

The docs promise property and value names are matched loosely
(whitespace not significant), but _normalize() only removed spaces.
Now tab/newline/cr/formfeed/vertical-tab are ignored as well.
@python-cla-bot

python-cla-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant