From 5028a2e1183fb3c8193e77242c517a745d1b4f58 Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Tue, 5 Jan 2021 11:05:40 +0000 Subject: [PATCH] Clarify logic about what instructions to line trace. --- Python/ceval.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 58ccf13521b..609215623b9 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -5000,8 +5000,11 @@ maybe_call_line_trace(Py_tracefunc func, PyObject *obj, */ int lastline = bounds->ar_line; int line = _PyCode_CheckLineNumber(frame->f_lasti, bounds); - if (frame->f_lasti < *instr_prev || (line != lastline && frame->f_lasti == bounds->ar_start)) { - if (line != -1 && frame->f_trace_lines) { + if (line != -1 && frame->f_trace_lines) { + /* Trace backward edges or first instruction of a new line */ + if (frame->f_lasti < *instr_prev || + (line != lastline && frame->f_lasti == bounds->ar_start)) + { frame->f_lineno = line; result = call_trace(func, obj, tstate, frame, PyTrace_LINE, Py_None); frame->f_lineno = 0;