Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix "invalid escape sequence" warnings before they become errors #208

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.

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
Rob-S opened this issue May 13, 2025 · 1 comment
Open

Fix "invalid escape sequence" warnings before they become errors #208

Rob-S opened this issue May 13, 2025 · 1 comment

Comments

@Rob-S
Copy link

Rob-S commented May 13, 2025

Fix "invalid escape sequence" warnings before they become errors

Per Deprecated Python behavior in Python 3.6

A backslash-character pair that is not a valid escape sequence now generates a DeprecationWarning. Although this will eventually become a SyntaxError, that will not be for several Python releases. (Contributed by Emanuel Barry in bpo-27364.)

In Python 3.12, invalid escape sequences started to generate a SyntaxWarning per Other Language Changes in Python 3.12:

A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+.\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw strings for regular expression: re.compile(r"\d+.\d+")). In a future Python version, SyntaxError will eventually be raised, instead of SyntaxWarning. (Contributed by Victor Stinner in gh-98401.)

Note that the SyntaxWarnings will become SyntaxErrors in a future Python version.

@Rob-S
Copy link
Author

Rob-S commented May 13, 2025

PR #209 fixes non-escaped backslashes in two places. Not sure if there are other places this needs to be applied.

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

No branches or pull requests

1 participant