Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b3f515a

Browse files
committed
Get the line number from PyCode_Addr2Line instead of believing
tb_lineno. Store it in tb_lineno for the user.
1 parent 747596a commit b3f515a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Python/traceback.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,14 @@ tb_printinternal(tb, f, limit)
243243
tb1 = tb1->tb_next;
244244
}
245245
while (tb != NULL && !intrcheck()) {
246-
if (depth <= limit)
246+
if (depth <= limit) {
247+
tb->tb_lineno = PyCode_Addr2Line(tb->tb_frame->f_code,
248+
tb->tb_lasti);
247249
tb_displayline(f,
248250
getstringvalue(tb->tb_frame->f_code->co_filename),
249251
tb->tb_lineno,
250252
getstringvalue(tb->tb_frame->f_code->co_name));
253+
}
251254
depth--;
252255
tb = tb->tb_next;
253256
}

0 commit comments

Comments
 (0)