@@ -3613,21 +3613,25 @@ compiler_try_except(struct compiler *c, stmt_ty s)
3613
3613
3614
3614
[orig, res, exc] <evaluate E1>
3615
3615
[orig, res, exc, E1] CHECK_EG_MATCH
3616
- [orig, red, rest/exc, match?] COPY 1
3617
- [orig, red, rest/exc, match?, match?] POP_JUMP_IF_NOT_NONE H1
3618
- [orig, red, exc, None] POP_TOP
3619
- [orig, red, exc] JUMP L2
3616
+ [orig, res, rest/exc, match?] COPY 1
3617
+ [orig, res, rest/exc, match?, match?] POP_JUMP_IF_NONE C1
3620
3618
3621
- [orig, res, rest, match] H1: <assign to V1> (or POP if no V1)
3619
+ [orig, res, rest, match] <assign to V1> (or POP if no V1)
3622
3620
3623
3621
[orig, res, rest] SETUP_FINALLY R1
3624
3622
[orig, res, rest] <code for S1>
3625
3623
[orig, res, rest] JUMP L2
3626
3624
3627
3625
[orig, res, rest, i, v] R1: LIST_APPEND 3 ) exc raised in except* body - add to res
3628
3626
[orig, res, rest, i] POP
3627
+ [orig, res, rest] JUMP LE2
3629
3628
3630
- [orig, res, rest] L2: <evaluate E2>
3629
+ [orig, res, rest] L2: NOP ) for lineno
3630
+ [orig, res, rest] JUMP LE2
3631
+
3632
+ [orig, res, rest/exc, None] C1: POP
3633
+
3634
+ [orig, res, rest] LE2: <evaluate E2>
3631
3635
.............................etc.......................
3632
3636
3633
3637
[orig, res, rest] Ln+1: LIST_APPEND 1 ) add unhandled exc to res (could be None)
@@ -3700,8 +3704,12 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
3700
3704
if (except == NULL ) {
3701
3705
return 0 ;
3702
3706
}
3703
- basicblock * handle_match = compiler_new_block (c );
3704
- if (handle_match == NULL ) {
3707
+ basicblock * except_with_error = compiler_new_block (c );
3708
+ if (except_with_error == NULL ) {
3709
+ return 0 ;
3710
+ }
3711
+ basicblock * no_match = compiler_new_block (c );
3712
+ if (no_match == NULL ) {
3705
3713
return 0 ;
3706
3714
}
3707
3715
if (i == 0 ) {
@@ -3725,13 +3733,9 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
3725
3733
VISIT (c , expr , handler -> v .ExceptHandler .type );
3726
3734
ADDOP (c , CHECK_EG_MATCH );
3727
3735
ADDOP_I (c , COPY , 1 );
3728
- ADDOP_JUMP (c , POP_JUMP_IF_NOT_NONE , handle_match );
3729
- ADDOP (c , POP_TOP ); // match
3730
- ADDOP_JUMP (c , JUMP , except );
3736
+ ADDOP_JUMP (c , POP_JUMP_IF_NONE , no_match );
3731
3737
}
3732
3738
3733
- compiler_use_next_block (c , handle_match );
3734
-
3735
3739
basicblock * cleanup_end = compiler_new_block (c );
3736
3740
if (cleanup_end == NULL ) {
3737
3741
return 0 ;
@@ -3793,8 +3797,14 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
3793
3797
ADDOP_I (c , LIST_APPEND , 3 ); // exc
3794
3798
ADDOP (c , POP_TOP ); // lasti
3795
3799
3796
- ADDOP_JUMP (c , JUMP , except );
3800
+ ADDOP_JUMP (c , JUMP , except_with_error );
3797
3801
compiler_use_next_block (c , except );
3802
+ ADDOP (c , NOP ); // to hold a propagated location info
3803
+ ADDOP_JUMP (c , JUMP , except_with_error );
3804
+ compiler_use_next_block (c , no_match );
3805
+ ADDOP (c , POP_TOP ); // match (None)
3806
+
3807
+ compiler_use_next_block (c , except_with_error );
3798
3808
3799
3809
if (i == n - 1 ) {
3800
3810
/* Add exc to the list (if not None it's the unhandled part of the EG) */
0 commit comments