summaryrefslogtreecommitdiff
path: root/Python/ast.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-12-01 08:40:23 +0200
committerGitHub <noreply@github.com>2017-12-01 08:40:23 +0200
commita561862048555d555fa4850eaf832ae5474c7e1f (patch)
treefca07e3ec3d93e8bc46a79e7211925ea7a2f2119 /Python/ast.c
parent73a7e9b10b2ec9636e3c6396cf7b3695f8ed1856 (diff)
downloadcpython-git-a561862048555d555fa4850eaf832ae5474c7e1f.tar.gz
Don't hide unexpected errors in PyErr_WarnExplicitObject(). (#4585)
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/Python/ast.c b/Python/ast.c
index e44ce51661..e2092f0f85 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -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;