Skip to content

Commit d544001

Browse files
fix warnings finalization bug
1 parent 539a4ca commit d544001

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Python/pystate.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,6 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
805805
_Py_ClearExecutorDeletionList(interp);
806806
#endif
807807
_PyAST_Fini(interp);
808-
_PyWarnings_Fini(interp);
809808
_PyAtExit_Fini(interp);
810809

811810
// All Python types must be destroyed before the last GC collection. Python
@@ -815,6 +814,10 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
815814
/* Last garbage collection on this interpreter */
816815
_PyGC_CollectNoFail(tstate);
817816
_PyGC_Fini(interp);
817+
818+
// Finalize warnings after last gc so that any finalizers can
819+
// access warnings state
820+
_PyWarnings_Fini(interp);
818821
struct _PyExecutorObject *cold = interp->cold_executor;
819822
if (cold != NULL) {
820823
interp->cold_executor = NULL;

0 commit comments

Comments
 (0)