diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-09-20 23:02:10 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-09-20 23:02:10 (GMT) |
commit | d4efd9eb1534eeead7f56c89d1b5e394d8633990 (patch) | |
tree | 434f841f14949c0c0e09b9012f1b22842ffae97a /Python/ast.c | |
parent | 2bc5c0be0141501c23eeb2bc96c33632443186ba (diff) | |
download | cpython-d4efd9eb1534eeead7f56c89d1b5e394d8633990.zip cpython-d4efd9eb1534eeead7f56c89d1b5e394d8633990.tar.gz cpython-d4efd9eb1534eeead7f56c89d1b5e394d8633990.tar.bz2 |
add column offset to all syntax errors
Diffstat (limited to 'Python/ast.c')
-rw-r--r-- | Python/ast.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Python/ast.c b/Python/ast.c index 9f6b7ea..38643f6 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -90,7 +90,7 @@ new_identifier(const char* n, PyArena *arena) static int ast_error(const node *n, const char *errstr) { - PyObject *u = Py_BuildValue("zi", errstr, LINENO(n)); + PyObject *u = Py_BuildValue("zii", errstr, LINENO(n), n->n_col_offset); if (!u) return 0; PyErr_SetObject(PyExc_SyntaxError, u); @@ -101,7 +101,7 @@ ast_error(const node *n, const char *errstr) static void ast_error_finish(const char *filename) { - PyObject *type, *value, *tback, *errstr, *loc, *tmp; + PyObject *type, *value, *tback, *errstr, *offset, *loc, *tmp; long lineno; assert(PyErr_Occurred()); @@ -118,6 +118,11 @@ ast_error_finish(const char *filename) Py_DECREF(errstr); return; } + offset = PyTuple_GetItem(value, 2); + if (!offset) { + Py_DECREF(errstr); + return; + } Py_DECREF(value); loc = PyErr_ProgramText(filename, lineno); @@ -125,7 +130,7 @@ ast_error_finish(const char *filename) Py_INCREF(Py_None); loc = Py_None; } - tmp = Py_BuildValue("(zlOO)", filename, lineno, Py_None, loc); + tmp = Py_BuildValue("(zlOO)", filename, lineno, offset, loc); Py_DECREF(loc); if (!tmp) { Py_DECREF(errstr); |