summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-09-02 14:25:18 -0400
committerBenjamin Peterson <benjamin@python.org>2012-09-02 14:25:18 -0400
commita22dbf2b6226f6f1893832cd5b886c16bc42996e (patch)
tree174b346a92dc0e82d3a5ff1b5108055aef3977c2 /Python
parentd4efa064827883d9f6cafe993b6f36cab4c3ddfa (diff)
parent3def60f886124d4867ac95ec82acfe99b5b2444d (diff)
downloadcpython-a22dbf2b6226f6f1893832cd5b886c16bc42996e.tar.gz
merge heads
Diffstat (limited to 'Python')
-rw-r--r--Python/ast.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/ast.c b/Python/ast.c
index fc6c565b21..5366dda406 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -588,7 +588,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;
}