From 2e2c903700991aa9f7e96d7a7fdaed3628dc7e1e Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 2 Sep 2012 14:23:15 -0400 Subject: prevert ast errors from being normalized before ast_error_finish is called (closes #15846) --- Python/ast.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Python') 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; } -- cgit v1.2.1