@@ -1745,6 +1745,7 @@ static int
1745
1745
compiler_unwind_fblock (struct compiler * c , struct fblockinfo * info ,
1746
1746
int preserve_tos )
1747
1747
{
1748
+ int loc ;
1748
1749
switch (info -> fb_type ) {
1749
1750
case WHILE_LOOP :
1750
1751
case EXCEPTION_HANDLER :
@@ -1797,6 +1798,8 @@ compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info,
1797
1798
1798
1799
case WITH :
1799
1800
case ASYNC_WITH :
1801
+ loc = c -> u -> u_lineno ;
1802
+ SET_LOC (c , (stmt_ty )info -> fb_datum );
1800
1803
ADDOP (c , POP_BLOCK );
1801
1804
if (preserve_tos ) {
1802
1805
ADDOP (c , ROT_TWO );
@@ -1810,6 +1813,7 @@ compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info,
1810
1813
ADDOP (c , YIELD_FROM );
1811
1814
}
1812
1815
ADDOP (c , POP_TOP );
1816
+ c -> u -> u_lineno = loc ;
1813
1817
return 1 ;
1814
1818
1815
1819
case HANDLER_CLEANUP :
@@ -4990,7 +4994,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos)
4990
4994
4991
4995
/* SETUP_ASYNC_WITH pushes a finally block. */
4992
4996
compiler_use_next_block (c , block );
4993
- if (!compiler_push_fblock (c , ASYNC_WITH , block , final , NULL )) {
4997
+ if (!compiler_push_fblock (c , ASYNC_WITH , block , final , s )) {
4994
4998
return 0 ;
4995
4999
}
4996
5000
@@ -5016,6 +5020,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos)
5016
5020
/* For successful outcome:
5017
5021
* call __exit__(None, None, None)
5018
5022
*/
5023
+ SET_LOC (c , s );
5019
5024
if (!compiler_call_exit_with_nones (c ))
5020
5025
return 0 ;
5021
5026
ADDOP (c , GET_AWAITABLE );
@@ -5028,7 +5033,6 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos)
5028
5033
5029
5034
/* For exceptional outcome: */
5030
5035
compiler_use_next_block (c , final );
5031
-
5032
5036
ADDOP (c , WITH_EXCEPT_START );
5033
5037
ADDOP (c , GET_AWAITABLE );
5034
5038
ADDOP_LOAD_CONST (c , Py_None );
@@ -5082,7 +5086,7 @@ compiler_with(struct compiler *c, stmt_ty s, int pos)
5082
5086
5083
5087
/* SETUP_WITH pushes a finally block. */
5084
5088
compiler_use_next_block (c , block );
5085
- if (!compiler_push_fblock (c , WITH , block , final , NULL )) {
5089
+ if (!compiler_push_fblock (c , WITH , block , final , s )) {
5086
5090
return 0 ;
5087
5091
}
5088
5092
@@ -5112,14 +5116,14 @@ compiler_with(struct compiler *c, stmt_ty s, int pos)
5112
5116
/* For successful outcome:
5113
5117
* call __exit__(None, None, None)
5114
5118
*/
5119
+ SET_LOC (c , s );
5115
5120
if (!compiler_call_exit_with_nones (c ))
5116
5121
return 0 ;
5117
5122
ADDOP (c , POP_TOP );
5118
5123
ADDOP_JUMP (c , JUMP_FORWARD , exit );
5119
5124
5120
5125
/* For exceptional outcome: */
5121
5126
compiler_use_next_block (c , final );
5122
-
5123
5127
ADDOP (c , WITH_EXCEPT_START );
5124
5128
compiler_with_except_finish (c );
5125
5129
0 commit comments