bpo-32912: Replace a DeprecationWarning with a SyntaxWarning (GH-9652)

for invalid escape sequences in string and bytes literals.
This commit is contained in:
Serhiy Storchaka 2018-10-19 17:42:06 +03:00 committed by GitHub
parent 209144831b
commit 6543912c90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 12 deletions

View file

@ -4128,14 +4128,14 @@ warn_invalid_escape_sequence(struct compiling *c, const node *n,
if (msg == NULL) {
return -1;
}
if (PyErr_WarnExplicitObject(PyExc_DeprecationWarning, msg,
if (PyErr_WarnExplicitObject(PyExc_SyntaxWarning, msg,
c->c_filename, LINENO(n),
NULL, NULL) < 0)
{
if (PyErr_ExceptionMatches(PyExc_DeprecationWarning)) {
if (PyErr_ExceptionMatches(PyExc_SyntaxWarning)) {
const char *s;
/* Replace the DeprecationWarning exception with a SyntaxError
/* Replace the SyntaxWarning exception with a SyntaxError
to get a more accurate error report */
PyErr_Clear();