mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #11393: _Py_DumpTraceback() writes the header even if there is no frame
This commit is contained in:
parent
a01ca12a52
commit
fcb88c4503
2 changed files with 9 additions and 11 deletions
|
@ -556,18 +556,19 @@ dump_frame(int fd, PyFrameObject *frame)
|
|||
write(fd, "\n", 1);
|
||||
}
|
||||
|
||||
static int
|
||||
static void
|
||||
dump_traceback(int fd, PyThreadState *tstate, int write_header)
|
||||
{
|
||||
PyFrameObject *frame;
|
||||
unsigned int depth;
|
||||
|
||||
frame = _PyThreadState_GetFrame(tstate);
|
||||
if (frame == NULL)
|
||||
return -1;
|
||||
|
||||
if (write_header)
|
||||
PUTS(fd, "Traceback (most recent call first):\n");
|
||||
|
||||
frame = _PyThreadState_GetFrame(tstate);
|
||||
if (frame == NULL)
|
||||
return;
|
||||
|
||||
depth = 0;
|
||||
while (frame != NULL) {
|
||||
if (MAX_FRAME_DEPTH <= depth) {
|
||||
|
@ -580,13 +581,12 @@ dump_traceback(int fd, PyThreadState *tstate, int write_header)
|
|||
frame = frame->f_back;
|
||||
depth++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
_Py_DumpTraceback(int fd, PyThreadState *tstate)
|
||||
{
|
||||
return dump_traceback(fd, tstate, 1);
|
||||
dump_traceback(fd, tstate, 1);
|
||||
}
|
||||
|
||||
/* Write the thread identifier into the file 'fd': "Current thread 0xHHHH:\" if
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue