diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-09-14 22:41:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-14 22:41:03 (GMT) |
commit | 3eae45f94da5b9cdc5aa14844d48871ab85bd537 (patch) | |
tree | aa13d6906f0c7072dce7179b9f8421ff647e6719 /Lib/test | |
parent | 5c7e8c3b72992bb668cafa101b71d8d14e395830 (diff) | |
download | cpython-3eae45f94da5b9cdc5aa14844d48871ab85bd537.zip cpython-3eae45f94da5b9cdc5aa14844d48871ab85bd537.tar.gz cpython-3eae45f94da5b9cdc5aa14844d48871ab85bd537.tar.bz2 |
[3.12] gh-105658: fix excess trace events for except block ending with a conditional block (#109384) (#109411)
gh-105658: fix excess trace events for except block ending with a conditional block (#109384)
(cherry picked from commit 4a54074a0f5579d417445ec28427cd0ed5aa01f4)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_sys_settrace.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index eef43e8..c29deeb 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -921,6 +921,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(): @@ -2092,7 +2121,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) |