Skip to content

Commit c482e32

Browse files
committed
fixup! [3.12] pythongh-109181: Speed up Traceback object creation by lazily compute the line number (pythonGH-111548)
1 parent db3d5b3 commit c482e32

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Python/traceback.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,8 +1024,16 @@ tb_printinternal(PyTracebackObject *tb, PyObject *f, long limit,
10241024
if (cnt <= TB_RECURSIVE_CUTOFF) {
10251025
if (tb_displayline(tb, f, code->co_filename, tb_lineno,
10261026
tb->tb_frame, code->co_name, indent, margin) < 0) {
1027+
goto error;
10271028
}
10281029

1030+
if (PyErr_CheckSignals() < 0) {
1031+
goto error;
1032+
}
1033+
}
1034+
Py_CLEAR(code);
1035+
tb = tb->tb_next;
1036+
}
10291037
if (cnt > TB_RECURSIVE_CUTOFF) {
10301038
if (tb_print_line_repeated(f, cnt) < 0) {
10311039
goto error;

0 commit comments

Comments
 (0)