Skip to content

Commit ece96f4

Browse files
committed
Move function cache clearing earlier in finalization
1 parent 1200014 commit ece96f4

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Python/pylifecycle.c

+5
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,11 @@ Py_FinalizeEx(void)
17671767
// XXX assert(_Py_IsMainInterpreter(tstate->interp));
17681768
// XXX assert(_Py_IsMainThread());
17691769

1770+
// The function version cache keeps functions alive, so clear it.
1771+
// It's used for optimizations, which we don't need in this stage.
1772+
tstate->interp->func_state.next_version = 0; // No more new versions
1773+
_PyFunction_ClearByVersionCache(tstate->interp);
1774+
17701775
// Block some operations.
17711776
tstate->interp->finalizing = 1;
17721777

Python/pystate.c

-3
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,6 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
840840
*/
841841
// XXX Make sure we properly deal with problematic finalizers.
842842

843-
interp->func_state.next_version = 0; // No more new versions
844-
_PyFunction_ClearByVersionCache(interp);
845-
846843
Py_CLEAR(interp->audit_hooks);
847844

848845
for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) {

0 commit comments

Comments
 (0)