Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix "invalid escape sequence" warnings before they become errors #208

Open
@Rob-S

Description

@Rob-S

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.

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