Skip to content

Commit

Permalink
Don't hide unexpected errors in PyErr_WarnExplicitObject(). (#4585)
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka committed Dec 1, 2017
1 parent 73a7e9b commit a561862
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Python/ast.c
Expand Up @@ -4160,18 +4160,19 @@ warn_invalid_escape_sequence(struct compiling *c, const node *n,
}
if (PyErr_WarnExplicitObject(PyExc_DeprecationWarning, msg,
c->c_filename, LINENO(n),
NULL, NULL) < 0 &&
PyErr_ExceptionMatches(PyExc_DeprecationWarning))
NULL, NULL) < 0)
{
const char *s;
if (PyErr_ExceptionMatches(PyExc_DeprecationWarning)) {
const char *s;

/* Replace the DeprecationWarning exception with a SyntaxError
to get a more accurate error report */
PyErr_Clear();
/* Replace the DeprecationWarning exception with a SyntaxError
to get a more accurate error report */
PyErr_Clear();

s = PyUnicode_AsUTF8(msg);
if (s != NULL) {
ast_error(c, n, s);
s = PyUnicode_AsUTF8(msg);
if (s != NULL) {
ast_error(c, n, s);
}
}
Py_DECREF(msg);
return -1;
Expand Down

0 comments on commit a561862

Please sign in to comment.