summaryrefslogtreecommitdiff
path: root/Python/ast.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-09-02 14:23:15 -0400
committerBenjamin Peterson <benjamin@python.org>2012-09-02 14:23:15 -0400
commite0772a2071aa586cac9007e810473379299b6cbd (patch)
tree889947b2be78c514fd03f9a6a67320c4b587ebcf /Python/ast.c
parent92ecb9733966c20fb628ce98e34647535b5f8e13 (diff)
downloadcpython-e0772a2071aa586cac9007e810473379299b6cbd.tar.gz
prevert ast errors from being normalized before ast_error_finish is called (closes #15846)
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 6faf5b21a6..3d0e3844b7 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -92,7 +92,15 @@ ast_error(const node *n, const char *errstr)
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;
}