[3.8] bpo-32912: Revert SyntaxWarning on invalid escape sequences (GH-15142)

* bpo-32912: Revert warnings for invalid escape sequences.

DeprecationWarning will continue to be emitted for invalid escape sequences in string and bytes literals in 3.8 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.
This commit is contained in:
Serhiy Storchaka 2019-08-10 01:34:22 +03:00 committed by Gregory P. Smith
parent 217077440a
commit 4c5b6bac24
6 changed files with 43 additions and 18 deletions

View file

@ -4674,12 +4674,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);