mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Add information about DeprecationWarning for invalid escaped characters in the re module (GH-5255)
This commit is contained in:
parent
b2dc4a3313
commit
e8239b8e81
1 changed files with 4 additions and 1 deletions
|
@ -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
|
a literal backslash, one might have to write ``'\\\\'`` as the pattern
|
||||||
string, because the regular expression must be ``\\``, and each
|
string, because the regular expression must be ``\\``, and each
|
||||||
backslash must be expressed as ``\\`` inside a regular Python string
|
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
|
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
|
patterns; backslashes are not handled in any special way in a string literal
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue