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.)
Seeing an warning on our django deployment:
drf_api_logger/utils.py:63: SyntaxWarning: invalid escape sequence '\g
I believe the string that includes the \g escape just needs to be an r-string (e.g.
r'\g<1>***FILTERED***\g<3>'
) to remove this warning.I believe this is due to a new Python 3.12 feature - second bullet point of https://docs.python.org/dev/whatsnew/3.12.html#other-language-changes - which also indicates this will become a SyntaxError in the future: