@@ -1796,7 +1796,6 @@ static int
1796
1796
compiler_unwind_fblock (struct compiler * c , struct fblockinfo * info ,
1797
1797
int preserve_tos )
1798
1798
{
1799
- int loc ;
1800
1799
switch (info -> fb_type ) {
1801
1800
case WHILE_LOOP :
1802
1801
case EXCEPTION_HANDLER :
@@ -1850,7 +1849,6 @@ compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info,
1850
1849
1851
1850
case WITH :
1852
1851
case ASYNC_WITH :
1853
- loc = c -> u -> u_lineno ;
1854
1852
SET_LOC (c , (stmt_ty )info -> fb_datum );
1855
1853
ADDOP (c , POP_BLOCK );
1856
1854
if (preserve_tos ) {
@@ -1865,7 +1863,10 @@ compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info,
1865
1863
ADDOP (c , YIELD_FROM );
1866
1864
}
1867
1865
ADDOP (c , POP_TOP );
1868
- c -> u -> u_lineno = loc ;
1866
+ /* The exit block should appear to execute after the
1867
+ * statement causing the unwinding, so make the unwinding
1868
+ * instruction artificial */
1869
+ c -> u -> u_lineno = -1 ;
1869
1870
return 1 ;
1870
1871
1871
1872
case HANDLER_CLEANUP :
@@ -3020,12 +3021,17 @@ compiler_return(struct compiler *c, stmt_ty s)
3020
3021
if (preserve_tos ) {
3021
3022
VISIT (c , expr , s -> v .Return .value );
3022
3023
} else {
3023
- /* Emit instruction with line number for expression */
3024
+ /* Emit instruction with line number for return value */
3024
3025
if (s -> v .Return .value != NULL ) {
3025
3026
SET_LOC (c , s -> v .Return .value );
3026
3027
ADDOP (c , NOP );
3027
3028
}
3028
3029
}
3030
+ if (s -> v .Return .value == NULL || s -> v .Return .value -> lineno != s -> lineno ) {
3031
+ SET_LOC (c , s );
3032
+ ADDOP (c , NOP );
3033
+ }
3034
+
3029
3035
if (!compiler_unwind_fblock_stack (c , preserve_tos , NULL ))
3030
3036
return 0 ;
3031
3037
if (s -> v .Return .value == NULL ) {
@@ -3044,6 +3050,8 @@ static int
3044
3050
compiler_break (struct compiler * c )
3045
3051
{
3046
3052
struct fblockinfo * loop = NULL ;
3053
+ /* Emit instruction with line number */
3054
+ ADDOP (c , NOP );
3047
3055
if (!compiler_unwind_fblock_stack (c , 0 , & loop )) {
3048
3056
return 0 ;
3049
3057
}
@@ -3062,6 +3070,8 @@ static int
3062
3070
compiler_continue (struct compiler * c )
3063
3071
{
3064
3072
struct fblockinfo * loop = NULL ;
3073
+ /* Emit instruction with line number */
3074
+ ADDOP (c , NOP );
3065
3075
if (!compiler_unwind_fblock_stack (c , 0 , & loop )) {
3066
3076
return 0 ;
3067
3077
}
@@ -4306,7 +4316,7 @@ maybe_optimize_method_call(struct compiler *c, expr_ty e)
4306
4316
ADDOP_I (c , CALL_METHOD_KW , argsl + kwdsl );
4307
4317
}
4308
4318
else {
4309
- ADDOP_I (c , CALL_METHOD , argsl );
4319
+ ADDOP_I (c , CALL_METHOD , argsl );
4310
4320
}
4311
4321
c -> u -> u_lineno = old_lineno ;
4312
4322
return 1 ;
@@ -4473,7 +4483,7 @@ compiler_subkwargs(struct compiler *c, asdl_keyword_seq *keywords, Py_ssize_t be
4473
4483
return 1 ;
4474
4484
}
4475
4485
4476
- /* Used by compiler_call_helper and maybe_optimize_method_call to emit
4486
+ /* Used by compiler_call_helper and maybe_optimize_method_call to emit
4477
4487
LOAD_CONST kw1
4478
4488
LOAD_CONST kw2
4479
4489
...
@@ -4484,7 +4494,7 @@ Returns 1 on success, 0 on error.
4484
4494
*/
4485
4495
static int
4486
4496
compiler_call_simple_kw_helper (struct compiler * c ,
4487
- asdl_keyword_seq * keywords ,
4497
+ asdl_keyword_seq * keywords ,
4488
4498
Py_ssize_t nkwelts )
4489
4499
{
4490
4500
PyObject * names ;
0 commit comments