Skip to content

Conversation

jaraco
Copy link
Owner

@jaraco jaraco commented Jun 8, 2025

  • gh-133306: Use \z instead of \Z in regular expressions in the stdlib (GH-133337)
  • Add a compatibility shim for Python 3.13 and earlier.

Comment on lines +26 to +31
def replace(pattern):
r"""
>>> replace(r'foo\z')
'foo\\Z'
"""
return pattern[:-2] + pattern[-2:].replace(r'\z', r'\Z')
Copy link
Owner Author

Choose a reason for hiding this comment

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

This could be made more generic, such as supporting \z not as the last pair of characters and supporting \\z (not replacing it), but I'm going to ignore those use-cases until they're potentially needed (such as making this compatibility shim more widely available).

@jaraco jaraco force-pushed the debt/backport-gh-133337 branch from 97cbade to 1b52c36 Compare June 8, 2025 16:48
@jaraco jaraco force-pushed the debt/backport-gh-133337 branch from 1b52c36 to 717d770 Compare June 8, 2025 16:52
@jaraco jaraco merged commit 5b5725d into main Jun 8, 2025
30 checks passed
@jaraco jaraco deleted the debt/backport-gh-133337 branch June 8, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants