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

Conversation

@Georgefifth

@Georgefifth Georgefifth commented Aug 24, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

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.

  • Issue: \p{...} names ignore only spaces, though the docs promise whitespace #156185

Sorry, something went wrong.

Uh oh!

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

All reactions
@python-cla-bot

python-cla-bot Bot commented Aug 24, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot added the awaiting review label Aug 24, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Aug 24, 2026
\p{...} names ignore only spaces, though the docs promise whitespace #156185
Open
serhiy-storchaka
serhiy-storchaka reviewed Aug 27, 2026
View reviewed changes
Comment thread Lib/re/_properties.py Outdated
# 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
# and hyphens and underscores are not significant, and an initial "is"

@serhiy-storchaka serhiy-storchaka Aug 27, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double "and".

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/re/_properties.py Outdated
# prefix is ignored (UAX #44 5.9, "Matching Rules", UAX44-LM3;
# https://www.unicode.org/reports/tr44/).
name = name.lower().replace("_", "").replace("-", "").replace(" ", "")
name = "".join(ch for ch in name.lower() if ch not in " \t\n\r\f\v_-")

@serhiy-storchaka serhiy-storchaka Aug 27, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is significantly slower than a sequence of replaces. The fastest method is to use translate() with predefined table created by str.maketrans().

Sorry, something went wrong.

Uh oh!

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

All reactions
serhiy-storchaka
serhiy-storchaka reviewed Aug 27, 2026
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, no NEWS entry is needed. This is a fix of an unreleased feature.

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app

bedevere-app Bot commented Aug 28, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

All reactions

Sorry, something went wrong.

Uh oh!

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

@Georgefifth
pythongh-156185: Ignore all ASCII whitespace in re \p{} property names
0bfce66
@Georgefifth
Georgefifth force-pushed the fix/re-property-whitespace branch from 8b94a7c to 0bfce66 Compare August 28, 2026 23:21
@bedevere-app

bedevere-app Bot commented Aug 28, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

All reactions

Sorry, something went wrong.

Uh oh!

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

Georgefifth
Georgefifth commented Aug 28, 2026
View reviewed changes

@Georgefifth Georgefifth left a comment

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three addressed in 0bfce66:

  • Double "and" — fixed, the comment now reads "case, whitespace, hyphens and underscores".
  • translate() — the strip is now name.lower().translate(_NON_SIGNIFICANT) with the table built once via str.maketrans("", "", " \t\n\r\f\v_-") at module level. Measured on a 33-char name: ~1.4x faster than the generator expression.
  • NEWS — removed; it is a fix to an unreleased feature, as you said.

test_re passes on a locally built interpreter (169 tests, 3 skipped, all pre-existing skips).

Sorry, something went wrong.

Uh oh!

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

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

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka left review comments

Uh oh!

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

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

@Georgefifth @serhiy-storchaka
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.