@@ -1745,6 +1745,7 @@ static int
17451745compiler_unwind_fblock (struct compiler * c , struct fblockinfo * info ,
17461746 int preserve_tos )
17471747{
1748+ int loc ;
17481749 switch (info -> fb_type ) {
17491750 case WHILE_LOOP :
17501751 case EXCEPTION_HANDLER :
@@ -1797,6 +1798,8 @@ compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info,
17971798
17981799 case WITH :
17991800 case ASYNC_WITH :
1801+ loc = c -> u -> u_lineno ;
1802+ SET_LOC (c , (stmt_ty )info -> fb_datum );
18001803 ADDOP (c , POP_BLOCK );
18011804 if (preserve_tos ) {
18021805 ADDOP (c , ROT_TWO );
@@ -1810,6 +1813,7 @@ compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info,
18101813 ADDOP (c , YIELD_FROM );
18111814 }
18121815 ADDOP (c , POP_TOP );
1816+ c -> u -> u_lineno = loc ;
18131817 return 1 ;
18141818
18151819 case HANDLER_CLEANUP :
@@ -4990,7 +4994,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos)
49904994
49914995 /* SETUP_ASYNC_WITH pushes a finally block. */
49924996 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 )) {
49944998 return 0 ;
49954999 }
49965000
@@ -5016,6 +5020,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos)
50165020 /* For successful outcome:
50175021 * call __exit__(None, None, None)
50185022 */
5023+ SET_LOC (c , s );
50195024 if (!compiler_call_exit_with_nones (c ))
50205025 return 0 ;
50215026 ADDOP (c , GET_AWAITABLE );
@@ -5028,7 +5033,6 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos)
50285033
50295034 /* For exceptional outcome: */
50305035 compiler_use_next_block (c , final );
5031-
50325036 ADDOP (c , WITH_EXCEPT_START );
50335037 ADDOP (c , GET_AWAITABLE );
50345038 ADDOP_LOAD_CONST (c , Py_None );
@@ -5082,7 +5086,7 @@ compiler_with(struct compiler *c, stmt_ty s, int pos)
50825086
50835087 /* SETUP_WITH pushes a finally block. */
50845088 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 )) {
50865090 return 0 ;
50875091 }
50885092
@@ -5112,14 +5116,14 @@ compiler_with(struct compiler *c, stmt_ty s, int pos)
51125116 /* For successful outcome:
51135117 * call __exit__(None, None, None)
51145118 */
5119+ SET_LOC (c , s );
51155120 if (!compiler_call_exit_with_nones (c ))
51165121 return 0 ;
51175122 ADDOP (c , POP_TOP );
51185123 ADDOP_JUMP (c , JUMP_FORWARD , exit );
51195124
51205125 /* For exceptional outcome: */
51215126 compiler_use_next_block (c , final );
5122-
51235127 ADDOP (c , WITH_EXCEPT_START );
51245128 compiler_with_except_finish (c );
51255129
0 commit comments