Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-32603: Deprecation warning on strings used in re module #5255

Merged
merged 1 commit into from Jan 20, 2019

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Jan 21, 2018

is complicated and hard to understand, so it's highly recommended that you use
raw strings for all but the simplest expressions.
sequence isn't recognized by Python's parser, it will generate a
:exc:`DeprecationWarning` and in the future this will become a :exc:`Syntaxerror`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Syntaxerror -> SyntaxError

@csabella
Copy link
Contributor

IMHO, I actually thought the warning about the DeprecationWarning and SyntaxError should come in one of the introduction paragraphs since the raw strings are discussed there.

In the paragraph that starts with, Regular expressions use the backslash character, maybe a line at the end with something like 'Also, please note that any invalid escape sequences in Python's usage of the backslash now generate a DeprecationWarning and, in the future, a SyntaxError. This will happen even if it is a valid escape sequence for a regular expression.'

@pablogsal
Copy link
Member Author

Thank you very much @csabella. I have added some lines as you suggested in the introductory paragraphs.

@@ -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 DeprecationWarning
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use a link to the DeprecationWarning exception like that

:exc:`DeprecationWarning`

same for the SyntaxError exception

@pablogsal
Copy link
Member Author

CC: @JulienPalard

@pablogsal pablogsal merged commit e8239b8 into python:master Jan 20, 2019
@pablogsal pablogsal deleted the bpo32603 branch January 20, 2019 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants