mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
bpo-32912: Replace a DeprecationWarning with a SyntaxWarning (GH-9652)
for invalid escape sequences in string and bytes literals.
This commit is contained in:
parent
209144831b
commit
6543912c90
6 changed files with 23 additions and 12 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue