@@ -3045,20 +3045,24 @@ compiler_try_except(struct compiler *c, stmt_ty s)
30453045   [orig, res, exc]                           <evaluate E1> 
30463046   [orig, res, exc, E1]                       CHECK_EG_MATCH 
30473047   [orig, res, rest/exc, match?]              COPY 1 
3048-    [orig, res, rest/exc, match?, match?]      POP_JUMP_IF_NOT_NONE  H1 
3049-    [orig, res, exc, None]                     POP_TOP 
3050-    [orig, res, exc]                           JUMP L2 
3048+    [orig, res, rest/exc, match?, match?]      POP_JUMP_IF_NONE      C1 
30513049
3052-    [orig, res, rest, match]         H1:        <assign to V1>  (or POP if no V1) 
3050+    [orig, res, rest, match]                    <assign to V1>  (or POP if no V1) 
30533051
30543052   [orig, res, rest]                          SETUP_FINALLY         R1 
30553053   [orig, res, rest]                          <code for S1> 
30563054   [orig, res, rest]                          JUMP                  L2 
30573055
30583056   [orig, res, rest, i, v]          R1:       LIST_APPEND   3 ) exc raised in except* body - add to res 
30593057   [orig, res, rest, i]                       POP 
3058+    [orig, res, rest]                          JUMP                  LE2 
30603059
3061-    [orig, res, rest]                L2:       <evaluate E2> 
3060+    [orig, res, rest]                L2:       NOP  ) for lineno 
3061+    [orig, res, rest]                          JUMP                  LE2 
3062+ 
3063+    [orig, res, rest/exc, None]      C1:       POP 
3064+ 
3065+    [orig, res, rest]               LE2:       <evaluate E2> 
30623066   .............................etc....................... 
30633067
30643068   [orig, res, rest]                Ln+1:     LIST_APPEND 1  ) add unhandled exc to res (could be None) 
@@ -3114,7 +3118,8 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
31143118        location  loc  =  LOC (handler );
31153119        NEW_JUMP_TARGET_LABEL (c , next_except );
31163120        except  =  next_except ;
3117-         NEW_JUMP_TARGET_LABEL (c , handle_match );
3121+         NEW_JUMP_TARGET_LABEL (c , except_with_error );
3122+         NEW_JUMP_TARGET_LABEL (c , no_match );
31183123        if  (i  ==  0 ) {
31193124            /* create empty list for exceptions raised/reraise in the except* blocks */ 
31203125            /* 
@@ -3132,13 +3137,9 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
31323137            VISIT (c , expr , handler -> v .ExceptHandler .type );
31333138            ADDOP (c , loc , CHECK_EG_MATCH );
31343139            ADDOP_I (c , loc , COPY , 1 );
3135-             ADDOP_JUMP (c , loc , POP_JUMP_IF_NOT_NONE , handle_match );
3136-             ADDOP (c , loc , POP_TOP );  // match 
3137-             ADDOP_JUMP (c , loc , JUMP , except );
3140+             ADDOP_JUMP (c , loc , POP_JUMP_IF_NONE , no_match );
31383141        }
31393142
3140-         USE_LABEL (c , handle_match );
3141- 
31423143        NEW_JUMP_TARGET_LABEL (c , cleanup_end );
31433144        NEW_JUMP_TARGET_LABEL (c , cleanup_body );
31443145
@@ -3197,9 +3198,16 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
31973198        /* add exception raised to the res list */ 
31983199        ADDOP_I (c , NO_LOCATION , LIST_APPEND , 3 ); // exc 
31993200        ADDOP (c , NO_LOCATION , POP_TOP ); // lasti 
3200-         ADDOP_JUMP (c , NO_LOCATION , JUMP , except );
3201+         ADDOP_JUMP (c , NO_LOCATION , JUMP , except_with_error );
32013202
32023203        USE_LABEL (c , except );
3204+         ADDOP (c , NO_LOCATION , NOP );  // to hold a propagated location info 
3205+         ADDOP_JUMP (c , NO_LOCATION , JUMP , except_with_error );
3206+ 
3207+         USE_LABEL (c , no_match );
3208+         ADDOP (c , loc , POP_TOP );  // match (None) 
3209+ 
3210+         USE_LABEL (c , except_with_error );
32033211
32043212        if  (i  ==  n  -  1 ) {
32053213            /* Add exc to the list (if not None it's the unhandled part of the EG) */ 
0 commit comments