[Python-checkins] Don't hide unexpected errors in PyErr_WarnExplicitObject(). (GH-4585) (#4662)

Serhiy Storchaka webhook-mailer at python.org
Fri Dec 1 02:21:47 EST 2017


https://github.com/python/cpython/commit/9881e4e5386bf6a74b4a542321c23a7c396035ef
commit: 9881e4e5386bf6a74b4a542321c23a7c396035ef
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2017-12-01T09:21:45+02:00
summary:

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

(cherry picked from commit a561862048555d555fa4850eaf832ae5474c7e1f)

files:
M Python/ast.c

diff --git a/Python/ast.c b/Python/ast.c
index d2710259acb..ede7f4fd990 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;



More information about the Python-checkins mailing list