diff Python/ast.c @ 78835:0db75a55145a 3.2

prevert ast errors from being normalized before ast_error_finish is called (closes #15846)
author Benjamin Peterson <benjamin@python.org>
date Sun, 02 Sep 2012 14:23:15 -0400
parents 5fe780c9638a
children a5e28f9924c3 d61424122af5
line wrap: on
line diff
--- a/Python/ast.c	Sat Sep 01 14:22:36 2012 +0300
+++ b/Python/ast.c	Sun Sep 02 14:23:15 2012 -0400
@@ -92,7 +92,15 @@
     PyObject *u = Py_BuildValue("zii", errstr, LINENO(n), n->n_col_offset);
     if (!u)
         return 0;
+    /*
+     * Prevent the error from being chained. PyErr_SetObject will normalize the
+     * exception in order to chain it. ast_error_finish, however, requires the
+     * error not to be normalized.
+     */
+    PyObject *save = PyThreadState_GET()->exc_value;
+    PyThreadState_GET()->exc_value = NULL;
     PyErr_SetObject(PyExc_SyntaxError, u);
+    PyThreadState_GET()->exc_value = save;
     Py_DECREF(u);
     return 0;
 }