@@ -1028,13 +1028,13 @@ forbidden_name(struct compiling *c, identifier name, const node *n,
10281028}
10291029
10301030static expr_ty
1031- copy_location (expr_ty e , const node * n )
1031+ copy_location (expr_ty e , const node * n , const node * end )
10321032{
10331033 if (e ) {
10341034 e -> lineno = LINENO (n );
10351035 e -> col_offset = n -> n_col_offset ;
1036- e -> end_lineno = n -> n_end_lineno ;
1037- e -> end_col_offset = n -> n_end_col_offset ;
1036+ e -> end_lineno = end -> n_end_lineno ;
1037+ e -> end_col_offset = end -> n_end_col_offset ;
10381038 }
10391039 return e ;
10401040}
@@ -2464,10 +2464,10 @@ ast_for_atom(struct compiling *c, const node *n)
24642464 }
24652465
24662466 if (TYPE (CHILD (ch , 1 )) == comp_for ) {
2467- return copy_location (ast_for_genexp (c , ch ), n );
2467+ return copy_location (ast_for_genexp (c , ch ), n , n );
24682468 }
24692469 else {
2470- return copy_location (ast_for_testlist (c , ch ), n );
2470+ return copy_location (ast_for_testlist (c , ch ), n , n );
24712471 }
24722472 case LSQB : /* list (or list comprehension) */
24732473 ch = CHILD (n , 1 );
@@ -2486,7 +2486,7 @@ ast_for_atom(struct compiling *c, const node *n)
24862486 n -> n_end_lineno , n -> n_end_col_offset , c -> c_arena );
24872487 }
24882488 else {
2489- return copy_location (ast_for_listcomp (c , ch ), n );
2489+ return copy_location (ast_for_listcomp (c , ch ), n , n );
24902490 }
24912491 case LBRACE : {
24922492 /* dictorsetmaker: ( ((test ':' test | '**' test)
@@ -2527,7 +2527,7 @@ ast_for_atom(struct compiling *c, const node *n)
25272527 /* It's a dictionary display. */
25282528 res = ast_for_dictdisplay (c , ch );
25292529 }
2530- return copy_location (res , n );
2530+ return copy_location (res , n , n );
25312531 }
25322532 }
25332533 default :
@@ -3146,7 +3146,7 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func,
31463146 }
31473147 else if (TYPE (CHILD (ch , 1 )) == comp_for ) {
31483148 /* the lone generator expression */
3149- e = copy_location (ast_for_genexp (c , ch ), maybegenbeg );
3149+ e = copy_location (ast_for_genexp (c , ch ), maybegenbeg , closepar );
31503150 if (!e )
31513151 return NULL ;
31523152 asdl_seq_SET (args , nargs ++ , e );
0 commit comments