[Python-checkins] Add information about DeprecationWarning for invalid escaped characters in the re module (GH-5255)

Pablo Galindo webhook-mailer at python.org
Sun Jan 20 13:58:00 EST 2019


https://github.com/python/cpython/commit/e8239b8e8199b76ef647ff3bf080ce2eb7733e04
commit: e8239b8e8199b76ef647ff3bf080ce2eb7733e04
branch: master
author: Pablo Galindo <Pablogsal at gmail.com>
committer: GitHub <noreply at github.com>
date: 2019-01-20T18:57:56Z
summary:

Add information about DeprecationWarning for invalid escaped characters in the re module (GH-5255)

files:
M Doc/library/re.rst

diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index 2f829559ff17..ac6455a22074 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -28,7 +28,10 @@ character for the same purpose in string literals; for example, to match
 a literal backslash, one might have to write ``'\\\\'`` as the pattern
 string, because the regular expression must be ``\\``, and each
 backslash must be expressed as ``\\`` inside a regular Python string
-literal.
+literal. Also, please note that any invalid escape sequences in Python's
+usage of the backslash in string literals now generate a :exc:`DeprecationWarning`
+and in the future this will become a :exc:`SyntaxError`. This behaviour
+will happen even if it is a valid escape sequence for a regular expression.
 
 The solution is to use Python's raw string notation for regular expression
 patterns; backslashes are not handled in any special way in a string literal



More information about the Python-checkins mailing list