Skip to content
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

SyntaxWarning on line 63 of utils.py in Python 3.12 #94

Closed
gwachob opened this issue Mar 18, 2024 · 1 comment
Closed

SyntaxWarning on line 63 of utils.py in Python 3.12 #94

gwachob opened this issue Mar 18, 2024 · 1 comment

Comments

@gwachob
Copy link

gwachob commented Mar 18, 2024

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:

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.)

@vishalanandl177
Copy link
Owner

The issue is now fixed, it will be part of the next release.

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

2 participants