diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-12-01 07:21:45 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-12-01 07:21:45 (GMT) |
commit | 9881e4e5386bf6a74b4a542321c23a7c396035ef (patch) | |
tree | 206651faf9b0f21b2222cf170283306d463da9d5 /Python | |
parent | 8bcd41040a5f1f9b48a86d0e21f196e4b1f90e4b (diff) | |
download | cpython-9881e4e5386bf6a74b4a542321c23a7c396035ef.zip cpython-9881e4e5386bf6a74b4a542321c23a7c396035ef.tar.gz cpython-9881e4e5386bf6a74b4a542321c23a7c396035ef.tar.bz2 |
Don't hide unexpected errors in PyErr_WarnExplicitObject(). (GH-4585) (#4662)
(cherry picked from commit a561862048555d555fa4850eaf832ae5474c7e1f)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ast.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Python/ast.c b/Python/ast.c index d271025..ede7f4f 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -4136,18 +4136,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; |