Skip to content

Commit 8f14607

Browse files
committed
bpo-45890: Add test cases for tracing of except
1 parent 2234e44 commit 8f14607

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

Lib/test/test_sys_settrace.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff 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:

0 commit comments

Comments
 (0)