@@ -3562,46 +3562,45 @@ compiler_try_star_finally(struct compiler *c, stmt_ty s)
3562
3562
NEW_JUMP_TARGET_LABEL (c , exit );
3563
3563
NEW_JUMP_TARGET_LABEL (c , cleanup );
3564
3564
/* `try` block */
3565
- _ADDOP_JUMP (c , loc , SETUP_FINALLY , end );
3565
+ ADDOP_JUMP (c , loc , SETUP_FINALLY , end );
3566
3566
3567
3567
USE_LABEL (c , body );
3568
- if (compiler_push_fblock (c , loc , FINALLY_TRY , body , end , s -> v .TryStar .finalbody ) < 0 ) {
3569
- return 0 ;
3570
- }
3568
+ RETURN_IF_ERROR (
3569
+ compiler_push_fblock (c , loc , FINALLY_TRY , body , end ,
3570
+ s -> v .TryStar .finalbody ));
3571
+
3571
3572
if (s -> v .TryStar .handlers && asdl_seq_LEN (s -> v .TryStar .handlers )) {
3572
- if (!compiler_try_star_except (c , s )) {
3573
- return 0 ;
3574
- }
3573
+ RETURN_IF_ERROR (compiler_try_star_except (c , s ));
3575
3574
}
3576
3575
else {
3577
- _VISIT_SEQ (c , stmt , s -> v .TryStar .body );
3576
+ VISIT_SEQ (c , stmt , s -> v .TryStar .body );
3578
3577
}
3579
- _ADDOP (c , NO_LOCATION , POP_BLOCK );
3578
+ ADDOP (c , NO_LOCATION , POP_BLOCK );
3580
3579
compiler_pop_fblock (c , FINALLY_TRY , body );
3581
- _VISIT_SEQ (c , stmt , s -> v .TryStar .finalbody );
3580
+ VISIT_SEQ (c , stmt , s -> v .TryStar .finalbody );
3582
3581
3583
- _ADDOP_JUMP (c , NO_LOCATION , JUMP , exit );
3582
+ ADDOP_JUMP (c , NO_LOCATION , JUMP , exit );
3584
3583
3585
3584
/* `finally` block */
3586
3585
USE_LABEL (c , end );
3587
3586
3588
3587
loc = NO_LOCATION ;
3589
- _ADDOP_JUMP (c , loc , SETUP_CLEANUP , cleanup );
3590
- _ADDOP (c , loc , PUSH_EXC_INFO );
3591
- if ( compiler_push_fblock ( c , loc , FINALLY_END , end , NO_LABEL , NULL ) < 0 ) {
3592
- return 0 ;
3593
- }
3594
- _VISIT_SEQ (c , stmt , s -> v .TryStar .finalbody );
3588
8000
+ ADDOP_JUMP (c , loc , SETUP_CLEANUP , cleanup );
3589
+ ADDOP (c , loc , PUSH_EXC_INFO );
3590
+ RETURN_IF_ERROR (
3591
+ compiler_push_fblock ( c , loc , FINALLY_END , end , NO_LABEL , NULL )) ;
3592
+
3593
+ VISIT_SEQ (c , stmt , s -> v .TryStar .finalbody );
3595
3594
loc = location_of_last_executing_statement (s -> v .Try .finalbody );
3596
3595
3597
3596
compiler_pop_fblock (c , FINALLY_END , end );
3598
- _ADDOP_I (c , loc , RERAISE , 0 );
3597
+ ADDOP_I (c , loc , RERAISE , 0 );
3599
3598
3600
3599
USE_LABEL (c , cleanup );
3601
- _POP_EXCEPT_AND_RERAISE (c , loc );
3600
+ POP_EXCEPT_AND_RERAISE (c , loc );
3602
3601
3603
3602
USE_LABEL (c , exit );
3604
- return 1 ;
3603
+ return SUCCESS ;
3605
3604
}
3606
3605
3607
3606
@@ -3820,27 +3819,27 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
3820
3819
NEW_JUMP_TARGET_LABEL (c , cleanup );
3821
3820
NEW_JUMP_TARGET_LABEL (c , reraise_star );
3822
3821
3823
- _ADDOP_JUMP (c , loc , SETUP_FINALLY , except );
3822
+ ADDOP_JUMP (c , loc , SETUP_FINALLY , except );
3824
3823
3825
3824
USE_LABEL (c , body );
3826
- if (compiler_push_fblock (c , loc , TRY_EXCEPT , body , NO_LABEL , NULL ) < 0 ) {
3827
- return 0 ;
3828
- }
3829
- _VISIT_SEQ (c , stmt , s -> v .TryStar .body );
3825
+ RETURN_IF_ERROR (
3826
+ compiler_push_fblock (c , loc , TRY_EXCEPT , body , NO_LABEL , NULL ));
3827
+ VISIT_SEQ (c , stmt , s -> v .TryStar .body );
3830
3828
compiler_pop_fblock (c , TRY_EXCEPT , body );
3831
- _ADDOP (c , NO_LOCATION , POP_BLOCK );
3832
- _ADDOP_JUMP (c , NO_LOCATION , JUMP , orelse );
3829
+ ADDOP (c , NO_LOCATION , POP_BLOCK );
3830
+ ADDOP_JUMP (c , NO_LOCATION , JUMP , orelse );
3833
3831
Py_ssize_t n = asdl_seq_LEN (s -> v .TryStar .handlers );
3834
3832
3835
3833
USE_LABEL (c , except );
3836
3834
3837
- _ADDOP_JUMP (c , NO_LOCATION , SETUP_CLEANUP , cleanup );
3838
- _ADDOP (c , NO_LOCATION , PUSH_EXC_INFO );
3835
+ ADDOP_JUMP (c , NO_LOCATION , SETUP_CLEANUP , cleanup );
3836
+ ADDOP (c , NO_LOCATION , PUSH_EXC_INFO );
3837
+
3839
3838
/* Runtime will push a block here, so we need to account for that */
3840
- if ( compiler_push_fblock ( c , loc , EXCEPTION_GROUP_HANDLER ,
3841
- NO_LABEL , NO_LABEL , "except handler" ) < 0 ) {
3842
- return 0 ;
3843
- }
3839
+ RETURN_IF_ERROR (
3840
+ compiler_push_fblock ( c , loc , EXCEPTION_GROUP_HANDLER ,
3841
+ NO_LABEL , NO_LABEL , "except handler" )) ;
3842
+
3844
3843
for (Py_ssize_t i = 0 ; i < n ; i ++ ) {
3845
3844
excepthandler_ty handler = (excepthandler_ty )asdl_seq_GET (
3846
3845
s -> v .TryStar .handlers , i );
@@ -3854,24 +3853,24 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
3854
3853
[exc] COPY 1
3855
3854
[orig, exc]
3856
3855
*/
3857
- _ADDOP_I (c , loc , COPY , 1 );
3856
+ ADDOP_I (c , loc , COPY , 1 );
3858
3857
3859
3858
/* create empty list for exceptions raised/reraise in the except* blocks */
3860
3859
/*
3861
3860
[orig, exc] BUILD_LIST
3862
3861
[orig, exc, []] SWAP 2
3863
3862
[orig, [], exc]
3864
3863
*/
3865
- _ADDOP_I (c , loc , BUILD_LIST , 0 );
3866
- _ADDOP_I (c , loc , SWAP , 2 );
3864
+ ADDOP_I (c , loc , BUILD_LIST , 0 );
3865
+ ADDOP_I (c , loc , SWAP , 2 );
3867
3866
}
3868
3867
if (handler -> v .ExceptHandler .type ) {
3869
- _VISIT (c , expr , handler -> v .ExceptHandler .type );
3870
- _ADDOP (c , loc , CHECK_EG_MATCH );
3871
- _ADDOP_I (c , loc , COPY , 1 );
3872
- _ADDOP_JUMP (c , loc , POP_JUMP_IF_NOT_NONE , handle_match );
3873
- _ADDOP (c , loc , POP_TOP ); // match
3874
- _ADDOP_JUMP (c , loc , JUMP , except );
3868
+ VISIT (c , expr , handler -> v .ExceptHandler .type );
3869
+ ADDOP (c , loc , CHECK_EG_MATCH );
3870
+ ADDOP_I (c , loc , COPY , 1 );
3871
+ ADDOP_JUMP (c , loc , POP_JUMP_IF_NOT_NONE , handle_match );
3872
+ ADDOP (c , loc , POP_TOP ); // match
3873
+ ADDOP_JUMP (c , loc , JUMP , except );
3875
3874
}
3876
3875
3877
3876
USE_LABEL (c , handle_match );
@@ -3883,7 +3882,7 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
3883
3882
compiler_nameop (c , loc , handler -> v .ExceptHandler .name , Store );
3884
3883
}
3885
3884
else {
3886
- _ADDOP (c , loc , POP_TOP ); // match
3885
+ ADDOP (c , loc , POP_TOP ); // match
3887
3886
}
3888
3887
3889
3888
/*
@@ -3897,77 +3896,77 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
3897
3896
del name
3898
3897
*/
3899
3898
/* second try: */
3900
- _ADDOP_JUMP (c , loc , SETUP_CLEANUP , cleanup_end );
3899
+ ADDOP_JUMP (c , loc , SETUP_CLEANUP , cleanup_end );
3901
3900
3902
3901
USE_LABEL (c , cleanup_body );
3903
- if ( compiler_push_fblock ( c , loc , HANDLER_CLEANUP , cleanup_body , NO_LABEL , handler -> v . ExceptHandler . name ) < 0 ) {
3904
- return 0 ;
3905
- }
3902
+ RETURN_IF_ERROR (
3903
+ compiler_push_fblock ( c , loc , HANDLER_CLEANUP , cleanup_body ,
3904
+ NO_LABEL , handler -> v . ExceptHandler . name ));
3906
3905
3907
3906
/* second # body */
3908
- _VISIT_SEQ (c , stmt , handler -> v .ExceptHandler .body );
3907
+ VISIT_SEQ (c , stmt , handler -> v .ExceptHandler .body );
3909
3908
compiler_pop_fblock (c , HANDLER_CLEANUP , cleanup_body );
3910
3909
/* name = None; del name; # artificial */
3911
- _ADDOP (c , NO_LOCATION , POP_BLOCK );
3910
+ ADDOP (c , NO_LOCATION , POP_BLOCK );
3912
3911
if (handler -> v .ExceptHandler .name ) {
3913
- _ADDOP_LOAD_CONST (c , NO_LOCATION , Py_None );
3912
+ ADDOP_LOAD_CONST (c , NO_LOCATION , Py_None );
3914
3913
compiler_nameop (c , NO_LOCATION , handler -> v .ExceptHandler .name , Store );
3915
3914
compiler_nameop (c , NO_LOCATION , handler -> v .ExceptHandler .name , Del );
3916
3915
}
3917
- _ADDOP_JUMP (c , NO_LOCATION , JUMP , except );
3916
+ ADDOP_JUMP (c , NO_LOCATION , JUMP , except );
3918
3917
3919
3918
/* except: */
3920
3919
USE_LABEL (c , cleanup_end );
3921
3920
3922
3921
/* name = None; del name; # artificial */
3923
3922
if (handler -> v .ExceptHandler .name ) {
3924
- _ADDOP_LOAD_CONST (c , NO_LOCATION , Py_None );
3923
+ ADDOP_LOAD_CONST (c , NO_LOCATION , Py_None );
3925
3924
compiler_nameop (c , NO_LOCATION , handler -> v .ExceptHandler .name , Store );
3926
3925
compiler_nameop (c , NO_LOCATION , handler -> v .ExceptHandler .name , Del );
3927
3926
}
3928
3927
3929
3928
/* add exception raised to the res list */
3930
- _ADDOP_I (c , NO_LOCATION , LIST_APPEND , 3 ); // exc
3931
- _ADDOP (c , NO_LOCATION , POP_TOP ); // lasti
3932
- _ADDOP_JUMP (c , NO_LOCATION , JUMP , except );
3929
+ ADDOP_I (c , NO_LOCATION , LIST_APPEND , 3 ); // exc
3930
+ ADDOP (c , NO_LOCATION , POP_TOP ); // lasti
3931
+ ADDOP_JUMP (c , NO_LOCATION , JUMP , except );
3933
3932
3934
3933
USE_LABEL (c , except );
3935
3934
3936
3935
if (i == n - 1 ) {
3937
3936
/* Add exc to the list (if not None it's the unhandled part of the EG) */
3938
- _ADDOP_I (c , NO_LOCATION , LIST_APPEND , 1 );
3939
- _ADDOP_JUMP (c , NO_LOCATION , JUMP , reraise_star );
3937
+ ADDOP_I (c , NO_LOCATION , LIST_APPEND , 1 );
3938
+ ADDOP_JUMP (c , NO_LOCATION , JUMP , reraise_star );
3940
3939
}
3941
3940
}
3942
3941
/* artificial */
3943
3942
compiler_pop_fblock (c , EXCEPTION_GROUP_HANDLER , NO_LABEL );
3944
3943
NEW_JUMP_TARGET_LABEL (c , reraise );
3945
3944
3946
3945
USE_LABEL (c , reraise_star );
3947
- _ADDOP (c , NO_LOCATION , PREP_RERAISE_STAR );
3948
- _ADDOP_I (c , NO_LOCATION , COPY , 1 );
3949
- _ADDOP_JUMP (c , NO_LOCATION , POP_JUMP_IF_NOT_NONE , reraise );
3946
+ ADDOP (c , NO_LOCATION , PREP_RERAISE_STAR );
3947
+ ADDOP_I (c , NO_LOCATION , COPY , 1 );
3948
+ ADDOP_JUMP (c , NO_LOCATION , POP_JUMP_IF_NOT_NONE , reraise );
3950
3949
3951
3950
/* Nothing to reraise */
3952
- _ADDOP (c , NO_LOCATION , POP_TOP );
3953
- _ADDOP (c , NO_LOCATION , POP_BLOCK );
3954
- _ADDOP (c , NO_LOCATION , POP_EXCEPT );
3955
- _ADDOP_JUMP (c , NO_LOCATION , JUMP , end );
3951
+ ADDOP (c , NO_LOCATION , POP_TOP );
3952
+ ADDOP (c , NO_LOCATION , POP_BLOCK );
3953
+ ADDOP (c , NO_LOCATION , POP_EXCEPT );
3954
+ ADDOP_JUMP (c , NO_LOCATION , JUMP , end );
3956
3955
3957
3956
USE_LABEL (c , reraise );
3958
- _ADDOP (c , NO_LOCATION , POP_BLOCK );
3959
- _ADDOP_I (c , NO_LOCATION , SWAP , 2 );
3960
- _ADDOP (c , NO_LOCATION , POP_EXCEPT );
3961
- _ADDOP_I (c , NO_LOCATION , RERAISE , 0 );
3957
+ ADDOP (c , NO_LOCATION , POP_BLOCK );
3958
+ ADDOP_I (c , NO_LOCATION , SWAP , 2 );
3959
+ ADDOP (c , NO_LOCATION , POP_EXCEPT );
3960
+ ADDOP_I (c , NO_LOCATION , RERAISE , 0 );
3962
3961
3963
3962
USE_LABEL (c , cleanup );
3964
- _POP_EXCEPT_AND_RERAISE (c , NO_LOCATION );
3963
+ POP_EXCEPT_AND_RERAISE (c , NO_LOCATION );
3965
3964
3966
3965
USE_LABEL (c , orelse );
3967
- _VISIT_SEQ (c , stmt , s -> v .TryStar .orelse );
3966
+ VISIT_SEQ (c , stmt , s -> v .TryStar .orelse );
3968
3967
3969
3968
USE_LABEL (c , end );
3970
- return 1 ;
3969
+ return SUCCESS ;
3971
3970
}
3972
3971
3973
3972
static int
@@ -3982,10 +3981,10 @@ static int
3982
3981
compiler_try_star (struct compiler * c , stmt_ty s )
3983
3982
{
3984
3983
if (s -> v .TryStar .finalbody && asdl_seq_LEN (s -> v .TryStar .finalbody )) {
3985
- return compiler_try_star_finally (c , s );
3984
+ return compiler_try_star_finally (c , s ) == SUCCESS ? 1 : 0 ;
3986
3985
}
3987
3986
else {
3988
- return compiler_try_star_except (c , s );
3987
+ return compiler_try_star_except (c , s ) == SUCCESS ? 1 : 0 ;
3989
3988
}
3990
3989
}
3991
3990
0 commit comments