Mercurial > cpython-lru_cache-weakref
diff Python/traceback.c @ 69102:7e3ed426962f
Issue #11393: _Py_DumpTraceback() writes the header even if there is no frame
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Fri, 01 Apr 2011 15:34:01 +0200 |
| parents | b0680b5a5215 |
| children | 7b8d625eb6e4 |
line wrap: on
line diff
--- a/Python/traceback.c Fri Apr 01 12:56:17 2011 +0200 +++ b/Python/traceback.c Fri Apr 01 15:34:01 2011 +0200 @@ -556,18 +556,19 @@ write(fd, "\n", 1); } -static int +static void dump_traceback(int fd, PyThreadState *tstate, int write_header) { PyFrameObject *frame; unsigned int depth; + if (write_header) + PUTS(fd, "Traceback (most recent call first):\n"); + frame = _PyThreadState_GetFrame(tstate); if (frame == NULL) - return -1; + return; - if (write_header) - PUTS(fd, "Traceback (most recent call first):\n"); depth = 0; while (frame != NULL) { if (MAX_FRAME_DEPTH <= depth) { @@ -580,13 +581,12 @@ 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
