Title: Raise non-silent warning for invalid escape sequences
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.8
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ebarry, ncoghlan, r.david.murray, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-02-22 18:34 by ebarry, last changed 2018-10-19 14:42 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 5849 closed ebarry, 2018-02-24 14:10
PR 9652 merged serhiy.storchaka, 2018-10-01 08:01
Messages (5)
msg312575 - (view) Author: Emanuel Barry (ebarry) * (Python triager) Date: 2018-02-22 18:34
This is a follow-up to Issue27364.

Back in Python 3.6, a silent warning was added for all invalid escape sequences in str and bytes. It was suggested that it would remain a silent warning (which still impacts tests, while not visually annoying the average user) for two releases (3.6 and 3.7), then would be upgraded to a non-silent warning for two subsequent releases (3.8 and 3.9) before becoming a full-on syntax error. With the 3.7 feature freeze on and going, I think it's time to evaluate the approach we take for 3.8 :)

I suggest upgrading the DeprecationWarning to a SyntaxWarning, which is visible by default, for 3.8 and 3.9. I have cross-linked #27364 to this issue as well.

msg312610 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2018-02-23 01:54
+1 for the DeprecationWarning->SyntaxWarning->SyntaxError approach from me (especially as 3.7 will make the existing deprecation warning visible in interactive shells and __main__ modules by default).
msg312760 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-02-24 21:32
PR 5849 changes not only the Python parser, but codecs. It shouldn't. The Python parser and codecs will go different ways. The warning in the Python parser will finally be upgraded to SyntaxError (it is already replaced with SyntaxError if the warning is raised as error). The warning in codecs will become UnicodeDecodeError or ValueError. This is why the code for emitting the warning is not shared between the parser and codecs at first place.
msg326766 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-01 08:06
Since the author of PR 5849 had not the time to work on it, I have created PR 9652 which properly replaces a DeprecationWarning with a SyntaxWarning. It also updates the documentation.
msg328044 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-19 14:42
New changeset 6543912c90ffa579dc4c01e811f9609cf92197d3 by Serhiy Storchaka in branch 'master':
bpo-32912: Replace a DeprecationWarning with a SyntaxWarning (GH-9652)
Date User Action Args
2018-10-19 14:42:31serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-10-19 14:42:13serhiy.storchakasetmessages: + msg328044
2018-10-01 08:06:22serhiy.storchakasetmessages: + msg326766
2018-10-01 08:01:09serhiy.storchakasetpull_requests: + pull_request9043
2018-02-24 21:32:40serhiy.storchakasetmessages: + msg312760
2018-02-24 14:10:24ebarrysetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request5625
2018-02-23 01:54:10ncoghlansetmessages: + msg312610
2018-02-22 19:20:53serhiy.storchakasetnosy: + ncoghlan, r.david.murray, serhiy.storchaka
2018-02-22 18:34:57ebarrycreate