@@ -3067,20 +3067,24 @@ compiler_try_except(struct compiler *c, stmt_ty s)
30673067 [orig, res, exc] <evaluate E1>
30683068 [orig, res, exc, E1] CHECK_EG_MATCH
30693069 [orig, res, rest/exc, match?] COPY 1
3070- [orig, res, rest/exc, match?, match?] POP_JUMP_IF_NOT_NONE H1
3071- [orig, res, exc, None] POP_TOP
3072- [orig, res, exc] JUMP L2
3070+ [orig, res, rest/exc, match?, match?] POP_JUMP_IF_NONE C1
30733071
3074- [orig, res, rest, match] H1: <assign to V1> (or POP if no V1)
3072+ [orig, res, rest, match] <assign to V1> (or POP if no V1)
30753073
30763074 [orig, res, rest] SETUP_FINALLY R1
30773075 [orig, res, rest] <code for S1>
30783076 [orig, res, rest] JUMP L2
30793077
30803078 [orig, res, rest, i, v] R1: LIST_APPEND 3 ) exc raised in except* body - add to res
30813079 [orig, res, rest, i] POP
3080+ [orig, res, rest] JUMP LE2
30823081
3083- [orig, res, rest] L2: <evaluate E2>
3082+ [orig, res, rest] L2: NOP ) for lineno
3083+ [orig, res, rest] JUMP LE2
3084+
3085+ [orig, res, rest/exc, None] C1: POP
3086+
3087+ [orig, res, rest] LE2: <evaluate E2>
30843088 .............................etc.......................
30853089
30863090 [orig, res, rest] Ln+1: LIST_APPEND 1 ) add unhandled exc to res (could be None)
@@ -3136,7 +3140,8 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
31363140 location loc = LOC (handler );
31373141 NEW_JUMP_TARGET_LABEL (c , next_except );
31383142 except = next_except ;
3139- NEW_JUMP_TARGET_LABEL (c , handle_match );
3143+ NEW_JUMP_TARGET_LABEL (c , except_with_error );
3144+ NEW_JUMP_TARGET_LABEL (c , no_match );
31403145 if (i == 0 ) {
31413146 /* create empty list for exceptions raised/reraise in the except* blocks */
31423147 /*
@@ -3154,13 +3159,9 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
31543159 VISIT (c , expr , handler -> v .ExceptHandler .type );
31553160 ADDOP (c , loc , CHECK_EG_MATCH );
31563161 ADDOP_I (c , loc , COPY , 1 );
3157- ADDOP_JUMP (c , loc , POP_JUMP_IF_NOT_NONE , handle_match );
3158- ADDOP (c , loc , POP_TOP ); // match
3159- ADDOP_JUMP (c , loc , JUMP , except );
3162+ ADDOP_JUMP (c , loc , POP_JUMP_IF_NONE , no_match );
31603163 }
31613164
3162- USE_LABEL (c , handle_match );
3163-
31643165 NEW_JUMP_TARGET_LABEL (c , cleanup_end );
31653166 NEW_JUMP_TARGET_LABEL (c , cleanup_body );
31663167
@@ -3219,9 +3220,16 @@ compiler_try_star_except(struct compiler *c, stmt_ty s)
32193220 /* add exception raised to the res list */
32203221 ADDOP_I (c , NO_LOCATION , LIST_APPEND , 3 ); // exc
32213222 ADDOP (c , NO_LOCATION , POP_TOP ); // lasti
3222- ADDOP_JUMP (c , NO_LOCATION , JUMP , except );
3223+ ADDOP_JUMP (c , NO_LOCATION , JUMP , except_with_error );
32233224
32243225 USE_LABEL (c , except );
3226+ ADDOP (c , NO_LOCATION , NOP ); // to hold a propagated location info
3227+ ADDOP_JUMP (c , NO_LOCATION , JUMP , except_with_error );
3228+
3229+ USE_LABEL (c , no_match );
3230+ ADDOP (c , loc , POP_TOP ); // match (None)
3231+
3232+ USE_LABEL (c , except_with_error );
32253233
32263234 if (i == n - 1 ) {
32273235 /* Add exc to the list (if not None it's the unhandled part of the EG) */
0 commit comments