[Python-checkins] Don't hide unexpected errors in PyErr_WarnExplicitObject(). (#4585)
Serhiy Storchaka
webhook-mailer at python.org
Fri Dec 1 01:40:26 EST 2017
https://github.com/python/cpython/commit/a561862048555d555fa4850eaf832ae5474c7e1f
commit: a561862048555d555fa4850eaf832ae5474c7e1f
branch: master
author: Serhiy Storchaka <storchaka at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017-12-01T08:40:23+02:00
summary:
Don't hide unexpected errors in PyErr_WarnExplicitObject(). (#4585)
files:
M Python/ast.c
diff --git a/Python/ast.c b/Python/ast.c
index e44ce516617..e2092f0f854 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;
More information about the Python-checkins
mailing list