File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -1077,6 +1077,29 @@ def func():
1077
1077
(1 , 'line' ),
1078
1078
(1 , 'return' )])
1079
1079
1080
+ def test_no_tracing_of_named_except_cleanup (self ):
1081
+
1082
+ def func ():
1083
+ x = 0
1084
+ try :
1085
+ 1 / x
1086
+ except ZeroDivisionError as error :
1087
+ if x :
1088
+ raise
1089
+ return "done"
1090
+
1091
+ self .run_and_compare (func ,
1092
+ [(0 , 'call' ),
1093
+ (1 , 'line' ),
1094
+ (2 , 'line' ),
1095
+ (3 , 'line' ),
1096
+ (3 , 'exception' ),
1097
+ (4 , 'line' ),
1098
+ (5 , 'line' ),
1099
+ (7 , 'line' ),
1100
+ (7 , 'return' )])
1101
+
1102
+
1080
1103
class SkipLineEventsTraceTestCase (TraceTestCase ):
1081
1104
"""Repeat the trace tests, but with per-line events skipped"""
1082
1105
Original file line number Diff line number Diff line change @@ -3220,10 +3220,10 @@ compiler_try_except(struct compiler *c, stmt_ty s)
3220
3220
/* second # body */
3221
3221
VISIT_SEQ (c , stmt , handler -> v .ExceptHandler .body );
3222
3222
compiler_pop_fblock (c , HANDLER_CLEANUP , cleanup_body );
3223
- ADDOP (c , POP_BLOCK );
3224
- ADDOP (c , POP_EXCEPT );
3225
3223
/* name = None; del name; # Mark as artificial */
3226
3224
c -> u -> u_lineno = -1 ;
3225
+ ADDOP (c , POP_BLOCK );
3226
+ ADDOP (c , POP_EXCEPT );
3227
3227
ADDOP_LOAD_CONST (c , Py_None );
3228
3228
compiler_nameop (c , handler -> v .ExceptHandler .name , Store );
3229
3229
compiler_nameop (c , handler -> v .ExceptHandler .name , Del );
@@ -3254,7 +3254,6 @@ compiler_try_except(struct compiler *c, stmt_ty s)
3254
3254
return 0 ;
3255
3255
VISIT_SEQ (c , stmt , handler -> v .ExceptHandler .body );
3256
3256
compiler_pop_fblock (c , HANDLER_CLEANUP , cleanup_body );
3257
- /* name = None; del name; # Mark as artificial */
3258
3257
c -> u -> u_lineno = -1 ;
3259
3258
ADDOP (c , POP_EXCEPT );
3260
3259
ADDOP_JUMP (c , JUMP_FORWARD , end );
You can’t perform that action at this time.
0 commit comments