Skip to content

Commit 9881e4e

Browse files
miss-islingtonserhiy-storchaka
authored andcommitted
Don't hide unexpected errors in PyErr_WarnExplicitObject(). (GH-4585) (#4662)
(cherry picked from commit a561862)
1 parent 8bcd410 commit 9881e4e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Python/ast.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4136,18 +4136,19 @@ warn_invalid_escape_sequence(struct compiling *c, const node *n,
41364136
}
41374137
if (PyErr_WarnExplicitObject(PyExc_DeprecationWarning, msg,
41384138
c->c_filename, LINENO(n),
4139-
NULL, NULL) < 0 &&
4140-
PyErr_ExceptionMatches(PyExc_DeprecationWarning))
4139+
NULL, NULL) < 0)
41414140
{
4142-
const char *s;
4141+
if (PyErr_ExceptionMatches(PyExc_DeprecationWarning)) {
4142+
const char *s;
41434143

4144-
/* Replace the DeprecationWarning exception with a SyntaxError
4145-
to get a more accurate error report */
4146-
PyErr_Clear();
4144+
/* Replace the DeprecationWarning exception with a SyntaxError
4145+
to get a more accurate error report */
4146+
PyErr_Clear();
41474147

4148-
s = PyUnicode_AsUTF8(msg);
4149-
if (s != NULL) {
4150-
ast_error(c, n, s);
4148+
s = PyUnicode_AsUTF8(msg);
4149+
if (s != NULL) {
4150+
ast_error(c, n, s);
4151+
}
41514152
}
41524153
Py_DECREF(msg);
41534154
return -1;

0 commit comments

Comments
 (0)