@@ -4315,7 +4315,7 @@ validate_keywords(struct compiler *c, asdl_keyword_seq *keywords)
4315
4315
for (Py_ssize_t j = i + 1 ; j < nkeywords ; j ++ ) {
4316
4316
keyword_ty other = ((keyword_ty )asdl_seq_GET (keywords , j ));
4317
4317
if (other -> arg && !PyUnicode_Compare (key -> arg , other -> arg )) {
4318
- c -> u -> u_col_offset = other -> col_offset ;
4318
+ SET_LOC ( c , other ) ;
4319
4319
compiler_error (c , "keyword argument repeated: %U" , key -> arg );
4320
4320
return -1 ;
4321
4321
}
@@ -5368,11 +5368,15 @@ static int
5368
5368
compiler_visit_expr (struct compiler * c , expr_ty e )
5369
5369
{
5370
5370
int old_lineno = c -> u -> u_lineno ;
5371
+ int old_end_lineno = c -> u -> u_end_lineno ;
5371
5372
int old_col_offset = c -> u -> u_col_offset ;
5373
+ int old_end_col_offset = c -> u -> u_end_col_offset ;
5372
5374
SET_LOC (c , e );
5373
5375
int res = compiler_visit_expr1 (c , e );
5374
5376
c -> u -> u_lineno = old_lineno ;
5377
+ c -> u -> u_end_lineno = old_end_lineno ;
5375
5378
c -> u -> u_col_offset = old_col_offset ;
5379
+ c -> u -> u_end_col_offset = old_end_col_offset ;
5376
5380
return res ;
5377
5381
}
5378
5382
@@ -5383,7 +5387,9 @@ compiler_augassign(struct compiler *c, stmt_ty s)
5383
5387
expr_ty e = s -> v .AugAssign .target ;
5384
5388
5385
5389
int old_lineno = c -> u -> u_lineno ;
5390
+ int old_end_lineno = c -> u -> u_end_lineno ;
5386
5391
int old_col_offset = c -> u -> u_col_offset ;
5392
+ int old_end_col_offset = c -> u -> u_end_col_offset ;
5387
5393
SET_LOC (c , e );
5388
5394
5389
5395
switch (e -> kind ) {
@@ -5413,7 +5419,9 @@ compiler_augassign(struct compiler *c, stmt_ty s)
5413
5419
}
5414
5420
5415
5421
c -> u -> u_lineno = old_lineno ;
5422
+ c -> u -> u_end_lineno = old_end_lineno ;
5416
5423
c -> u -> u_col_offset = old_col_offset ;
5424
+ c -> u -> u_end_col_offset = old_end_col_offset ;
5417
5425
5418
5426
VISIT (c , expr , s -> v .AugAssign .value );
5419
5427
ADDOP (c , inplace_binop (s -> v .AugAssign .op ));
@@ -5934,14 +5942,14 @@ validate_kwd_attrs(struct compiler *c, asdl_identifier_seq *attrs, asdl_pattern_
5934
5942
Py_ssize_t nattrs = asdl_seq_LEN (attrs );
5935
5943
for (Py_ssize_t i = 0 ; i < nattrs ; i ++ ) {
5936
5944
identifier attr = ((identifier )asdl_seq_GET (attrs , i ));
5937
- c -> u -> u_col_offset = ((pattern_ty ) asdl_seq_GET (patterns , i ))-> col_offset ;
5945
+ SET_LOC ( c , ((pattern_ty ) asdl_seq_GET (patterns , i ))) ;
5938
5946
if (forbidden_name (c , attr , Store )) {
5939
5947
return -1 ;
5940
5948
}
5941
5949
for (Py_ssize_t j = i + 1 ; j < nattrs ; j ++ ) {
5942
5950
identifier other = ((identifier )asdl_seq_GET (attrs , j ));
5943
5951
if (!PyUnicode_Compare (attr , other )) {
5944
- c -> u -> u_col_offset = ((pattern_ty ) asdl_seq_GET (patterns , j ))-> col_offset ;
5952
+ SET_LOC ( c , ((pattern_ty ) asdl_seq_GET (patterns , j ))) ;
5945
5953
compiler_error (c , "attribute name repeated in class pattern: %U" , attr );
5946
5954
return -1 ;
5947
5955
}
@@ -5972,7 +5980,7 @@ compiler_pattern_class(struct compiler *c, pattern_ty p, pattern_context *pc)
5972
5980
}
5973
5981
if (nattrs ) {
5974
5982
RETURN_IF_FALSE (!validate_kwd_attrs (c , kwd_attrs , kwd_patterns ));
5975
- c -> u -> u_col_offset = p -> col_offset ; // validate_kwd_attrs moves this
5983
+ SET_LOC ( c , p );
5976
5984
}
5977
5985
VISIT (c , expr , p -> v .MatchClass .cls );
5978
5986
PyObject * attr_names ;
@@ -6056,7 +6064,7 @@ compiler_pattern_mapping(struct compiler *c, pattern_ty p, pattern_context *pc)
6056
6064
if (key == NULL ) {
6057
6065
const char * e = "can't use NULL keys in MatchMapping "
6058
6066
"(set 'rest' parameter instead)" ;
6059
- c -> u -> u_col_offset = ((pattern_ty ) asdl_seq_GET (patterns , i ))-> col_offset ;
6067
+ SET_LOC ( c , ((pattern_ty ) asdl_seq_GET (patterns , i ))) ;
6060
6068
return compiler_error (c , e );
6061
6069
}
6062
6070
if (!MATCH_VALUE_EXPR (key )) {
0 commit comments