gh-105658: fix excess trace events for except block ending with a conditional block (#109384)

This commit is contained in:
Irit Katriel 2023-09-14 17:06:08 +01:00 committed by GitHub
parent 1ce9ea0453
commit 4a54074a0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 20 deletions

View file

@ -929,6 +929,35 @@ class TraceTestCase(unittest.TestCase):
(6, 'line'),
(6, 'return')])
def test_finally_with_conditional(self):
# See gh-105658
condition = True
def func():
try:
try:
raise Exception
finally:
if condition:
result = 1
result = 2
except:
result = 3
return result
self.run_and_compare(func,
[(0, 'call'),
(1, 'line'),
(2, 'line'),
(3, 'line'),
(3, 'exception'),
(5, 'line'),
(6, 'line'),
(8, 'line'),
(9, 'line'),
(10, 'line'),
(10, 'return')])
def test_break_to_continue1(self):
def func():
@ -2123,7 +2152,7 @@ class JumpTestCase(unittest.TestCase):
output.append(11)
output.append(12)
@jump_test(5, 11, [2, 4], (ValueError, 'exception'))
@jump_test(5, 11, [2, 4], (ValueError, 'comes after the current code block'))
def test_no_jump_over_return_try_finally_in_finally_block(output):
try:
output.append(2)