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

Fix "SyntaxWarning: invalid escape sequence" for regex compile function in Python 3.12 #591

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vietjovi
Copy link

There are language changes in Python 3.12 that prevents the regex pattern from retrieving IP addresses and protocol strings from proxy data. The fix was tested with versions 3.10, 3.11, and 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 python/cpython#98401.)

Reference: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes

@vietjovi vietjovi mentioned this pull request Nov 12, 2024
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.

1 participant