@@ -3613,21 +3613,25 @@ compiler_try_except(struct compiler *c, stmt_ty s)
36133613
36143614 [orig, res, exc] <evaluate E1>
36153615 [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
36203618
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)
36223620
36233621 [orig, res, rest] SETUP_FINALLY R1
36243622 [orig, res, rest] <code for S1>
36253623 [orig, res, rest] JUMP L2
36263624
36273625 [orig, res, rest, i, v] R1: LIST_APPEND 3 ) exc raised in except* body - add to res
36283626 [orig, res, rest, i] POP
3627+ [orig, res, rest] JUMP LE2
36293628
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>
36313635 .............................etc.......................
36323636
36333637 [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)
37003704 if (except == NULL ) {
37013705 return 0 ;
37023706 }
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 ) {
37053713 return 0 ;
37063714 }
37073715 if (i == 0 ) {
@@ -3725,13 +3733,9 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
37253733 VISIT (c , expr , handler -> v .ExceptHandler .type );
37263734 ADDOP (c , CHECK_EG_MATCH );
37273735 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 );
37313737 }
37323738
3733- compiler_use_next_block (c , handle_match );
3734-
37353739 basicblock * cleanup_end = compiler_new_block (c );
37363740 if (cleanup_end == NULL ) {
37373741 return 0 ;
@@ -3793,8 +3797,14 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
37933797 ADDOP_I (c , LIST_APPEND , 3 ); // exc
37943798 ADDOP (c , POP_TOP ); // lasti
37953799
3796- ADDOP_JUMP (c , JUMP , except );
3800+ ADDOP_JUMP (c , JUMP , except_with_error );
37973801 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 );
37983808
37993809 if (i == n - 1 ) {
38003810 /* Add exc to the list (if not None it's the unhandled part of the EG) */
0 commit comments