diff options
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Python/compile.c b/Python/compile.c index 49a713b..1b7a2e8 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -197,6 +197,8 @@ struct compiler_unit { int u_firstlineno; /* the first lineno of the block */ int u_lineno; /* the lineno for the current stmt */ int u_col_offset; /* the offset of the current stmt */ + int u_end_lineno; /* the end line of the current stmt */ + int u_end_col_offset; /* the end offset of the current stmt */ }; /* This struct captures the global state of a compilation. @@ -641,6 +643,8 @@ compiler_enter_scope(struct compiler *c, identifier name, u->u_firstlineno = lineno; u->u_lineno = 0; u->u_col_offset = 0; + u->u_end_lineno = 0; + u->u_end_col_offset = 0; u->u_consts = PyDict_New(); if (!u->u_consts) { compiler_unit_free(u); @@ -911,7 +915,9 @@ compiler_next_instr(basicblock *b) #define SET_LOC(c, x) \ (c)->u->u_lineno = (x)->lineno; \ - (c)->u->u_col_offset = (x)->col_offset; + (c)->u->u_col_offset = (x)->col_offset; \ + (c)->u->u_end_lineno = (x)->end_lineno; \ + (c)->u->u_end_col_offset = (x)->end_col_offset; /* Return the stack effect of opcode with argument oparg. @@ -5474,8 +5480,9 @@ compiler_error(struct compiler *c, const char *format, ...) Py_INCREF(Py_None); loc = Py_None; } - PyObject *args = Py_BuildValue("O(OiiO)", msg, c->c_filename, - c->u->u_lineno, c->u->u_col_offset + 1, loc); + PyObject *args = Py_BuildValue("O(OiiOii)", msg, c->c_filename, + c->u->u_lineno, c->u->u_col_offset + 1, loc, + c->u->u_end_lineno, c->u->u_end_col_offset + 1); Py_DECREF(msg); if (args == NULL) { goto exit; |