Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2e5e04

Browse files
committed
Py_FatalError: disable faulthandler earlier
Issue #26563: Py_FatalError: disable faulthandler before trying to flush sys.stdout and sys.stderr.
1 parent 6150f31 commit a2e5e04

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

Python/pylifecycle.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,17 +1354,17 @@ Py_FatalError(const char *msg)
13541354
if (!_Py_FatalError_PrintExc(fd))
13551355
_Py_FatalError_DumpTracebacks(fd);
13561356

1357+
/* The main purpose of faulthandler is to display the traceback. We already
1358+
* did our best to display it. So faulthandler can now be disabled.
1359+
* (Don't trigger it on abort().) */
1360+
_PyFaulthandler_Fini();
1361+
13571362
/* Check if the current Python thread hold the GIL */
13581363
if (PyThreadState_GET() != NULL) {
13591364
/* Flush sys.stdout and sys.stderr */
13601365
flush_std_files();
13611366
}
13621367

1363-
/* The main purpose of faulthandler is to display the traceback. We already
1364-
* did our best to display it. So faulthandler can now be disabled.
1365-
* (Don't trigger it on abort().) */
1366-
_PyFaulthandler_Fini();
1367-
13681368
#ifdef MS_WINDOWS
13691369
len = strlen(msg);
13701370

0 commit comments

Comments
 (0)