File tree Expand file tree Collapse file tree 2 files changed +51
-2
lines changed Expand file tree Collapse file tree 2 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -642,15 +642,18 @@ def func():
642642 2
643643 except :
644644 4
645- finally :
645+ else :
646646 6
647+ finally :
648+ 8
647649
648650 self .run_and_compare (func ,
649651 [(0 , 'call' ),
650652 (1 , 'line' ),
651653 (2 , 'line' ),
652654 (6 , 'line' ),
653- (6 , 'return' )])
655+ (8 , 'line' ),
656+ (8 , 'return' )])
654657
655658 def test_nested_loops (self ):
656659
@@ -1016,6 +1019,47 @@ def func():
10161019 (3 , 'line' ),
10171020 (3 , 'return' )])
10181021
1022+ def test_try_in_try_with_exception (self ):
1023+
1024+ def func ():
1025+ try :
1026+ try :
1027+ raise TypeError
1028+ except ValueError as ex :
1029+ 5
1030+ except TypeError :
1031+ 7
1032+
1033+ self .run_and_compare (func ,
1034+ [(0 , 'call' ),
1035+ (1 , 'line' ),
1036+ (2 , 'line' ),
1037+ (3 , 'line' ),
1038+ (3 , 'exception' ),
1039+ (4 , 'line' ),
1040+ (6 , 'line' ),
1041+ (7 , 'line' ),
1042+ (7 , 'return' )])
1043+
1044+ def func ():
1045+ try :
1046+ try :
1047+ raise ValueError
1048+ except ValueError as ex :
1049+ 5
1050+ except TypeError :
1051+ 7
1052+
1053+ self .run_and_compare (func ,
1054+ [(0 , 'call' ),
1055+ (1 , 'line' ),
1056+ (2 , 'line' ),
1057+ (3 , 'line' ),
1058+ (3 , 'exception' ),
1059+ (4 , 'line' ),
1060+ (5 , 'line' ),
1061+ (5 , 'return' )])
1062+
10191063 def test_if_in_if_in_if (self ):
10201064 def func (a = 0 , p = 1 , z = 1 ):
10211065 if p :
Original file line number Diff line number Diff line change 1111
1212from test .tracedmodules import testmod
1313
14+ ##
15+ ## See also test_sys_settrace.py, which contains tests that cover
16+ ## tracing of many more code blocks.
17+ ##
18+
1419#------------------------------- Utilities -----------------------------------#
1520
1621def fix_ext_py (filename ):
You can’t perform that action at this time.
0 commit comments