gh-156185: Ignore all ASCII whitespace in re \p{} property names - #156304
Open
Georgefifth wants to merge 1 commit into
Open
gh-156185: Ignore all ASCII whitespace in re \p{} property names#156304Georgefifth wants to merge 1 commit into
Georgefifth wants to merge 1 commit into
Conversation
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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The docs (and the
_normalizecomment) 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}raisedre.error: unknown property "L\ntu"while the space form worked. (3.16-only feature, so no compatibility concern.)Solution
_normalize()inLib/re/_properties.pynow 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; fulltest_repasses (169 tests) on a debug build, and the new assertions fail on the unpatched code. NEWS entry added.\p{...}names ignore only spaces, though the docs promise whitespace #156185