@@ -281,7 +281,9 @@ static int test_replace_main_tstate(void)
281
281
}
282
282
283
283
assert (PyThreadState_Get () == tstate );
284
- Py_Finalize ();
284
+ if (Py_FinalizeEx () != 0 ) {
285
+ err = 1 ;
286
+ }
285
287
286
288
return err ;
287
289
}
@@ -295,6 +297,7 @@ struct fini_subthread_args {
295
297
PyThreadState * main_tstate ;
296
298
PyInterpreterState * interp ;
297
299
PyMutex done ;
300
+ int rc ;
298
301
};
299
302
300
303
static void fini_with_new_tstate (void * arg )
@@ -310,7 +313,7 @@ static void fini_with_new_tstate(void *arg)
310
313
(void )PyThreadState_Swap (tstate );
311
314
312
315
assert (PyThreadState_Get () != args -> main_tstate );
313
- Py_Finalize ();
316
+ args -> rc = Py_FinalizeEx ();
314
317
315
318
PyMutex_Unlock (& args -> done );
316
319
}
@@ -331,7 +334,7 @@ static int test_fini_in_subthread(void)
331
334
PyMutex_Lock (& args .done );
332
335
PyMutex_Unlock (& args .done );
333
336
334
- return 0 ;
337
+ return args . rc ;
335
338
}
336
339
337
340
static 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)
343
346
(void )PyThreadState_Swap (tstate );
344
347
345
348
assert (PyThreadState_Get () != main_tstate );
346
- Py_Finalize ();
347
-
348
- return 0 ;
349
+ return Py_FinalizeEx ();
349
350
}
350
351
351
352
static int test_fini_in_main_thread_with_subinterpreter (void )
@@ -362,9 +363,7 @@ static int test_fini_in_main_thread_with_subinterpreter(void)
362
363
363
364
// The subinterpreter's tstate is still current.
364
365
assert (PyThreadState_Get () == substate );
365
- Py_Finalize ();
366
-
367
- return 0 ;
366
+ return Py_FinalizeEx ();
368
367
}
369
368
370
369
0 commit comments