Mercurial > cpython-lru_cache-weakref
diff Python/ast.c @ 64861:861c35cef7aa
add column offset to all syntax errors
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Mon, 20 Sep 2010 23:02:10 +0000 |
| parents | c18eeb969102 |
| children | 55ed5c524428 |
line wrap: on
line diff
--- a/Python/ast.c Mon Sep 20 23:01:33 2010 +0000 +++ b/Python/ast.c Mon Sep 20 23:02:10 2010 +0000 @@ -90,7 +90,7 @@ 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 @@ 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 @@ 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 @@ 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);
