diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2019-01-20 18:57:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-20 18:57:56 (GMT) |
commit | e8239b8e8199b76ef647ff3bf080ce2eb7733e04 (patch) | |
tree | e7971907516f779da3071c660c5de7b026f5f9aa | |
parent | b2dc4a3313c236fedbd6df664722cd47f3d91a72 (diff) | |
download | cpython-e8239b8e8199b76ef647ff3bf080ce2eb7733e04.zip cpython-e8239b8e8199b76ef647ff3bf080ce2eb7733e04.tar.gz cpython-e8239b8e8199b76ef647ff3bf080ce2eb7733e04.tar.bz2 |
Add information about DeprecationWarning for invalid escaped characters in the re module (GH-5255)
-rw-r--r-- | Doc/library/re.rst | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst index 2f82955..ac6455a 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 |