@@ -281,7 +281,9 @@ static int test_replace_main_tstate(void)
281281 }
282282
283283 assert (PyThreadState_Get () == tstate );
284- Py_Finalize ();
284+ if (Py_FinalizeEx () != 0 ) {
285+ err = 1 ;
286+ }
285287
286288 return err ;
287289}
@@ -295,6 +297,7 @@ struct fini_subthread_args {
295297 PyThreadState * main_tstate ;
296298 PyInterpreterState * interp ;
297299 PyMutex done ;
300+ int rc ;
298301};
299302
300303static void fini_with_new_tstate (void * arg )
@@ -310,7 +313,7 @@ static void fini_with_new_tstate(void *arg)
310313 (void )PyThreadState_Swap (tstate );
311314
312315 assert (PyThreadState_Get () != args -> main_tstate );
313- Py_Finalize ();
316+ args -> rc = Py_FinalizeEx ();
314317
315318 PyMutex_Unlock (& args -> done );
316319}
@@ -331,7 +334,7 @@ static int test_fini_in_subthread(void)
331334 PyMutex_Lock (& args .done );
332335 PyMutex_Unlock (& args .done );
333336
334- return 0 ;
337+ return args . rc ;
335338}
336339
337340static int test_fini_in_main_thread_with_other_tstate (void )
@@ -343,9 +346,7 @@ static int test_fini_in_main_thread_with_other_tstate(void)
343346 (void )PyThreadState_Swap (tstate );
344347
345348 assert (PyThreadState_Get () != main_tstate );
346- Py_Finalize ();
347-
348- return 0 ;
349+ return Py_FinalizeEx ();
349350}
350351
351352static int test_fini_in_main_thread_with_subinterpreter (void )
@@ -362,9 +363,7 @@ static int test_fini_in_main_thread_with_subinterpreter(void)
362363
363364 // The subinterpreter's tstate is still current.
364365 assert (PyThreadState_Get () == substate );
365- Py_Finalize ();
366-
367- return 0 ;
366+ return Py_FinalizeEx ();
368367}
369368
370369
0 commit comments