GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-156185: Ignore all ASCII whitespace in re \p{} property names by Georgefifth · Pull Request #156304 · python/cpython

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Georgefifth wants to merge 1 commit into python:main
base: main
Loading
Loading
from Georgefifth:fix/re-property-whitespace

Uh oh!

There was an error while loading. Please reload this page.

Open

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

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
0bfce66
gh-156185: Ignore all ASCII whitespace in re \p{} property names
Georgefifth Aug 28, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

13 changes: 9 additions & 4 deletions 13 Lib/re/_properties.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,17 @@ def _analytic_ranges():
}


# Characters that are not significant in a Unicode property or value name
# (see _normalize): ASCII whitespace, hyphens and underscores.
_NON_SIGNIFICANT = str.maketrans("", "", " \t\n\r\f\v_-")


def _normalize(name):
# Unicode property and value names are matched loosely: case, spaces,
# hyphens and underscores are not significant, and an initial "is" prefix
# is ignored (UAX #44 5.9, "Matching Rules", UAX44-LM3;
# Unicode property and value names are matched loosely: case, whitespace,
# hyphens and underscores are not significant, and an initial "is"
# prefix is ignored (UAX #44 5.9, "Matching Rules", UAX44-LM3;
# https://www.unicode.org/reports/tr44/).
name = name.lower().replace("_", "").replace("-", "").replace(" ", "")
name = name.lower().translate(_NON_SIGNIFICANT)
# Strip a leading "is", unless "is" is the whole name and so not a prefix
# (e.g. the Line_Break value lb=IS).
if name != "is":
Expand Down
6 changes: 6 additions & 0 deletions 6 Lib/test/test_re.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,12 @@ def test_property_escapes(self):
self.assertTrue(re.fullmatch(r'\p{General_Category=Lu}+', 'ABC'))
self.assertTrue(re.fullmatch(r'\p{ lu }+', 'ABC'))
self.assertTrue(re.fullmatch(r'\p{LU}+', 'ABC'))
# All ASCII whitespace is ignored, not just spaces (UAX44-LM3;
# gh-156185).
for ws in " \t\n\r\f\v":
with self.subTest(ws=ws):
self.assertTrue(re.fullmatch(r'\p{L%su}+' % ws, 'ABC'))
self.assertTrue(re.fullmatch(r'\p{gc%s=L%su}+' % (ws, ws), 'ABC'))
# An initial "is" prefix is ignored (UAX44-LM3), on the property name
# and on a gc value; "is" alone is not a prefix (cf. lb=IS).
self.assertTrue(re.fullmatch(r'\p{isLu}+', 'ABC'))
Expand Down
Loading
Oops, something went wrong.

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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.