]> granicus.if.org Git - python/commitdiff
Py_FatalError: disable faulthandler earlier
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 16 Mar 2016 22:19:15 +0000 (23:19 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 16 Mar 2016 22:19:15 +0000 (23:19 +0100)
Issue #26563: Py_FatalError: disable faulthandler before trying to flush
sys.stdout and sys.stderr.

Python/pylifecycle.c

index c4a6d7c955d9fd0ca97a00bf8186d25d4ba501ca..35ca88fd3b54043f0139841cd24acff0da30a858 100644 (file)
@@ -1354,17 +1354,17 @@ Py_FatalError(const char *msg)
     if (!_Py_FatalError_PrintExc(fd))
         _Py_FatalError_DumpTracebacks(fd);
 
+    /* The main purpose of faulthandler is to display the traceback. We already
+     * did our best to display it. So faulthandler can now be disabled.
+     * (Don't trigger it on abort().) */
+    _PyFaulthandler_Fini();
+
     /* Check if the current Python thread hold the GIL */
     if (PyThreadState_GET() != NULL) {
         /* Flush sys.stdout and sys.stderr */
         flush_std_files();
     }
 
-    /* The main purpose of faulthandler is to display the traceback. We already
-     * did our best to display it. So faulthandler can now be disabled.
-     * (Don't trigger it on abort().) */
-    _PyFaulthandler_Fini();
-
 #ifdef MS_WINDOWS
     len = strlen(msg);