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-133306: Support \z as a synonym for \Z in regular expressions by serhiy-storchaka · Pull Request #133314 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented May 2, 2025 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Issue: add \z as a synonym for \Z in Python REs for standardization #133306

📚 Documentation preview 📚: https://cpython-previews--133314.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

All reactions
@serhiy-storchaka
pythongh-133306: Support \z as a synonym for \Z in regular expressions
53aa233
@bedevere-app bedevere-app Bot mentioned this pull request May 2, 2025
add \z as a synonym for \Z in Python REs for standardization #133306
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label May 2, 2025
sethmlarson
sethmlarson approved these changes May 2, 2025
View reviewed changes

@sethmlarson sethmlarson left a comment

Copy link
Copy Markdown
Contributor

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.

LGTM, thanks Serhiy. I only had one thought on this PR:

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/re/_parser.py Outdated
r"\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]),
r"\Z": (AT, AT_END_STRING), # end of string
r"\z": (AT, AT_END_STRING), # end of string
r"\Z": (AT, AT_END_STRING), # end of string (deprecated)

@sethmlarson sethmlarson May 2, 2025

Copy link
Copy Markdown
Contributor

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.

Should we use "deprecated" language here if we're not deprecating \Z?

Sorry, something went wrong.

Uh oh!

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

All reactions

@serhiy-storchaka serhiy-storchaka May 2, 2025

Copy link
Copy Markdown
Member 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.

What words do you suggest? "legacy"? "obsolete"?

Due to its subtle difference from other common implementations, it is very likely that \Z will be deprecated and removed in future, when it will be safe. It is kept for compatibility with older Python versions.

Sorry, something went wrong.

Uh oh!

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

All reactions
serhiy-storchaka added 2 commits May 2, 2025 22:32
@serhiy-storchaka
Fix docs markup.
3964364
@serhiy-storchaka
"obsolete" instead of "deprecated".
cd99209
hugovk
hugovk approved these changes May 3, 2025
View reviewed changes

@hugovk hugovk 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.

Thank you for the PR! Please also run the buildbots before merge.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/whatsnew/3.14.rst Resolved

Uh oh!

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

Comment thread Doc/library/re.rst Resolved

Uh oh!

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

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels May 3, 2025
serhiy-storchaka and others added 2 commits May 3, 2025 10:10
@serhiy-storchaka
Move the directive.
d9b88b9
@serhiy-storchaka @hugovk
Update Doc/whatsnew/3.14.rst
4dfd574
Co-authored-by: Hugo van Kemenade <[email protected]>
@serhiy-storchaka

serhiy-storchaka commented May 3, 2025

Copy link
Copy Markdown
Member Author

Thank you for review. This feature is not platform-depended, so no need to spend the time and the resources on running the buildbots.

All reactions

Sorry, something went wrong.

Uh oh!

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

vstinner
vstinner approved these changes May 3, 2025
View reviewed changes

@vstinner vstinner 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.

LGTM

Sorry, something went wrong.

Uh oh!

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

All reactions
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) May 3, 2025 07:30
@serhiy-storchaka
serhiy-storchaka merged commit ac56f8c into python:main May 3, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label May 3, 2025
@serhiy-storchaka
serhiy-storchaka deleted the re-z branch May 3, 2025 09:41
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
@serhiy-storchaka @Pranjal095
pythongh-133306: Support \z as a synonym for \Z in regular expressions (
44327f4
pythonGH-133314)

\Z was an error inherited from PCRE 0.95. It was fixed in PCRE 2.0.
In other engines, \Z means not “anchor at string end”, but
“anchor before optional newline at string end”.

\z means “anchor at string end” in most RE engines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes
@hugovk hugovk hugovk approved these changes
@sethmlarson sethmlarson sethmlarson approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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.

4 participants

@serhiy-storchaka @vstinner @hugovk @sethmlarson
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 01402520 — 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.