alexa-skills-kit-sdk-for-python icon indicating copy to clipboard operation
alexa-skills-kit-sdk-for-python copied to clipboard

Fix "invalid escape sequence" warnings before they become errors

Open Rob-S opened this issue 6 months ago • 1 comments
trafficstars

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 avatar May 13 '25 17:05 Rob-S

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

Rob-S avatar May 13 '25 17:05 Rob-S