@@ -3512,7 +3512,8 @@ fatal_output_debug(const char *msg)
35123512
35133513
35143514static void
3515- fatal_error_dump_runtime (int fd , _PyRuntimeState * runtime )
3515+ fatal_error_dump_runtime (int fd , _PyRuntimeState * runtime ,
3516+ PyInterpreterState * interp )
35163517{
35173518 PUTS (fd , "Python runtime state: " );
35183519 PyThreadState * finalizing = _PyRuntimeState_GetFinalizing (runtime );
@@ -3521,6 +3522,9 @@ fatal_error_dump_runtime(int fd, _PyRuntimeState *runtime)
35213522 _Py_DumpHexadecimal (fd , (uintptr_t )finalizing , sizeof (finalizing ) * 2 );
35223523 PUTS (fd , ")" );
35233524 }
3525+ else if (interp != NULL && interp -> finalizing ) {
3526+ PUTS (fd , "finalizing" );
3527+ }
35243528 else if (_PyRuntimeState_GetInitialized (runtime )) {
35253529 PUTS (fd , "initialized" );
35263530 }
@@ -3726,9 +3730,6 @@ fatal_error(int fd, int header, const char *prefix, const char *msg,
37263730 PUTS (fd , "\n" );
37273731 }
37283732
3729- _PyRuntimeState * runtime = & _PyRuntime ;
3730- fatal_error_dump_runtime (fd , runtime );
3731-
37323733 /* Check if the current thread has a Python thread state
37333734 and holds the GIL.
37343735
@@ -3746,8 +3747,11 @@ fatal_error(int fd, int header, const char *prefix, const char *msg,
37463747 else if (tss_tstate != NULL ) {
37473748 interp = tss_tstate -> interp ;
37483749 }
3749- int has_tstate_and_gil = (tss_tstate != NULL && tss_tstate == tstate );
37503750
3751+ _PyRuntimeState * runtime = & _PyRuntime ;
3752+ fatal_error_dump_runtime (fd , runtime , interp );
3753+
3754+ int has_tstate_and_gil = (tss_tstate != NULL && tss_tstate == tstate );
37513755 if (has_tstate_and_gil ) {
37523756 /* If an exception is set, print the exception with its traceback */
37533757 if (!_Py_FatalError_PrintExc (tss_tstate )) {
0 commit comments