@@ -197,6 +197,8 @@ struct compiler_unit {
197
197
int u_firstlineno ; /* the first lineno of the block */
198
198
int u_lineno ; /* the lineno for the current stmt */
199
199
int u_col_offset ; /* the offset of the current stmt */
200
+ int u_end_lineno ; /* the end line of the current stmt */
201
+ int u_end_col_offset ; /* the end offset of the current stmt */
200
202
};
201
203
202
204
/* This struct captures the global state of a compilation.
@@ -641,6 +643,8 @@ compiler_enter_scope(struct compiler *c, identifier name,
641
643
u -> u_firstlineno = lineno ;
642
644
u -> u_lineno = 0 ;
643
645
u -> u_col_offset = 0 ;
646
+ u -> u_end_lineno = 0 ;
647
+ u -> u_end_col_offset = 0 ;
644
648
u -> u_consts = PyDict_New ();
645
649
if (!u -> u_consts ) {
646
650
compiler_unit_free (u );
@@ -911,7 +915,9 @@ compiler_next_instr(basicblock *b)
911
915
912
916
#define SET_LOC (c , x ) \
913
917
(c)->u->u_lineno = (x)->lineno; \
914
- (c)->u->u_col_offset = (x)->col_offset;
918
+ (c)->u->u_col_offset = (x)->col_offset; \
919
+ (c)->u->u_end_lineno = (x)->end_lineno; \
920
+ (c)->u->u_end_col_offset = (x)->end_col_offset;
915
921
916
922
/* Return the stack effect of opcode with argument oparg.
917
923
@@ -5474,8 +5480,9 @@ compiler_error(struct compiler *c, const char *format, ...)
5474
5480
Py_INCREF (Py_None );
5475
5481
loc = Py_None ;
5476
5482
}
5477
- PyObject * args = Py_BuildValue ("O(OiiO)" , msg , c -> c_filename ,
5478
- c -> u -> u_lineno , c -> u -> u_col_offset + 1 , loc );
5483
+ PyObject * args = Py_BuildValue ("O(OiiOi)" , msg , c -> c_filename ,
5484
+ c -> u -> u_lineno , c -> u -> u_col_offset + 1 , loc ,
5485
+ c -> u -> u_end_lineno , c -> u -> u_end_col_offset + 1 );
5479
5486
Py_DECREF (msg );
5480
5487
if (args == NULL ) {
5481
5488
goto exit ;
0 commit comments