Don't hide unexpected errors in PyErr_WarnExplicitObject(). (#4585)

This commit is contained in:
Serhiy Storchaka 2017-12-01 08:40:23 +02:00 committed by GitHub
parent 73a7e9b10b
commit a561862048
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 9 deletions

View File

@ -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;