]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #11393: _Py_DumpTraceback() writes the header even if there is no frame
authorVictor Stinner <victor.stinner@haypocalc.com>
Fri, 1 Apr 2011 13:34:01 +0000 (15:34 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Fri, 1 Apr 2011 13:34:01 +0000 (15:34 +0200)
Include/traceback.h
Python/traceback.c

index 9a8f2a63adbfe20d0b293493f1bce3dc6d315a1a..77347077e91a2746d0b5f7bbc94861ada64ebafa 100644 (file)
@@ -38,8 +38,6 @@ PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
          ...
          File "xxx", line xxx in <xxx>
 
-   Return 0 on success, -1 on error.
-
    This function is written for debug purpose only, to dump the traceback in
    the worst case: after a segmentation fault, at fatal error, etc. That's why,
    it is very limited. Strings are truncated to 100 characters and encoded to
@@ -49,7 +47,7 @@ PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
 
    This function is signal safe. */
 
-PyAPI_DATA(int) _Py_DumpTraceback(
+PyAPI_DATA(void) _Py_DumpTraceback(
     int fd,
     PyThreadState *tstate);
 
index 37673d93e04c81e79d47d61c2ae2e0e78e7b5e7f..f0142da7929cf0bdcb4d7e36e2f72ed855310d86 100644 (file)
@@ -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;
 
+    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 @@ 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