Skip to content

Commit 4238bad

Browse files
committed
Fix case with simple finally
1 parent 398fe55 commit 4238bad

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Lib/test/test_sys_settrace.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,27 @@ def func():
505505
(9, 'line'),
506506
(9, 'return')])
507507

508+
def test_19_except_with_finally(self):
509+
def func():
510+
try:
511+
try:
512+
raise Exception
513+
finally:
514+
y = "Something"
515+
except Exception:
516+
b = 23
517+
518+
self.run_and_compare(func,
519+
[(0, 'call'),
520+
(1, 'line'),
521+
(2, 'line'),
522+
(3, 'line'),
523+
(3, 'exception'),
524+
(5, 'line'),
525+
(6, 'line'),
526+
(7, 'line'),
527+
(7, 'return')])
528+
508529

509530
class SkipLineEventsTraceTestCase(TraceTestCase):
510531
"""Repeat the trace tests, but with per-line events skipped"""

Python/ceval.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3611,7 +3611,8 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
36113611
PUSH(exc);
36123612
JUMPTO(handler);
36133613
if (_Py_TracingPossible(ceval) &&
3614-
(f->f_lasti < instr_lb || f->f_lasti >= instr_ub)) {
3614+
((f->f_lasti < instr_lb || f->f_lasti >= instr_ub) ||
3615+
!(f->f_lasti == instr_lb || f->f_lasti < instr_prev))) {
36153616
/* Make sure that we trace line after exception */
36163617
instr_prev = INT_MAX;
36173618
}

0 commit comments

Comments
 (0)