Skip to content

Commit a561862

Browse files
Don't hide unexpected errors in PyErr_WarnExplicitObject(). (#4585)
1 parent 73a7e9b commit a561862

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
@@ -4160,18 +4160,19 @@ warn_invalid_escape_sequence(struct compiling *c, const node *n,
41604160
}
41614161
if (PyErr_WarnExplicitObject(PyExc_DeprecationWarning, msg,
41624162
c->c_filename, LINENO(n),
4163-
NULL, NULL) < 0 &&
4164-
PyErr_ExceptionMatches(PyExc_DeprecationWarning))
4163+
NULL, NULL) < 0)
41654164
{
4166-
const char *s;
4165+
if (PyErr_ExceptionMatches(PyExc_DeprecationWarning)) {
4166+
const char *s;
41674167

4168-
/* Replace the DeprecationWarning exception with a SyntaxError
4169-
to get a more accurate error report */
4170-
PyErr_Clear();
4168+
/* Replace the DeprecationWarning exception with a SyntaxError
4169+
to get a more accurate error report */
4170+
PyErr_Clear();
41714171

4172-
s = PyUnicode_AsUTF8(msg);
4173-
if (s != NULL) {
4174-
ast_error(c, n, s);
4172+
s = PyUnicode_AsUTF8(msg);
4173+
if (s != NULL) {
4174+
ast_error(c, n, s);
4175+
}
41754176
}
41764177
Py_DECREF(msg);
41774178
return -1;

0 commit comments

Comments
 (0)