mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-32912: Revert SyntaxWarning on invalid escape sequences. (GH-15195)
DeprecationWarning will continue to be emitted for invalid escape
sequences in string and bytes literals just as it did in 3.7.
SyntaxWarning may be emitted in the future. But per mailing list
discussion, we don't yet know when because we haven't settled on how to
do so in a non-disruptive manner.
(Applies 4c5b6bac24
to the master branch).
(This is https://github.com/python/cpython/pull/15142 for master/3.9)
https://bugs.python.org/issue32912
Automerge-Triggered-By: @gpshead
This commit is contained in:
parent
92c7e30adf
commit
b4be87a04a
6 changed files with 43 additions and 18 deletions
|
@ -4671,12 +4671,12 @@ warn_invalid_escape_sequence(struct compiling *c, const node *n,
|
|||
if (msg == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (PyErr_WarnExplicitObject(PyExc_SyntaxWarning, msg,
|
||||
if (PyErr_WarnExplicitObject(PyExc_DeprecationWarning, msg,
|
||||
c->c_filename, LINENO(n),
|
||||
NULL, NULL) < 0)
|
||||
{
|
||||
if (PyErr_ExceptionMatches(PyExc_SyntaxWarning)) {
|
||||
/* Replace the SyntaxWarning exception with a SyntaxError
|
||||
if (PyErr_ExceptionMatches(PyExc_DeprecationWarning)) {
|
||||
/* Replace the DeprecationWarning exception with a SyntaxError
|
||||
to get a more accurate error report */
|
||||
PyErr_Clear();
|
||||
ast_error(c, n, "%U", msg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue