Skip to content

SyntaxWarning: invalid escape sequence #883

@StanBorbatTR

Description

@StanBorbatTR

I get warnings when initializing 3.133.0 using Python 3.12. The messages are below:

/var/task/settings.py:169: SyntaxWarning: invalid escape sequence '\d'
"REDACT_IP", "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}", "xxx.xxx.xxx.xxx"
/var/task/settings.py:173: SyntaxWarning: invalid escape sequence '\.'
"[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+",
/var/task/steps/common.py:12: SyntaxWarning: invalid escape sequence '\d'
"\d+_CloudTrail(|-Digest|-Insight)_\w{2}(|-gov|-cn)-\w{4,9}-\d_(|.+)\d{8}T\d{4,6}Z(|.+).json.gz$",

It seems that Python 3.12 has made those Syntax Warnings.

Python 3.11

Python 3.11.10 (main, Sep  7 2024, 01:03:31) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> test = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"

Python 3.12

Python 3.12.7 (main, Oct  1 2024, 02:05:46) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> test = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"
<stdin>:1: SyntaxWarning: invalid escape sequence '\d'

Perhaps those should be marked as regular expressions like so:

Python 3.12.7 (main, Oct  1 2024, 02:05:46) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> test = r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions