From 3245947faef497c437bab2557a73a5611eb3ada1 Mon Sep 17 00:00:00 2001 From: Rostan Tabet Date: Wed, 22 Jan 2025 17:22:43 +0100 Subject: [PATCH] Finalize imports before tracemalloc Signed-off-by: Rostan Tabet --- Python/pylifecycle.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index ea8a291a8e5eb4..72b5d1ec1d6582 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -2127,15 +2127,15 @@ _Py_Finalize(_PyRuntimeState *runtime) _PyGC_CollectIfEnabled(); #endif - /* Disable tracemalloc after all Python objects have been destroyed, - so it is possible to use tracemalloc in objects destructor. */ - _PyTraceMalloc_Fini(); - /* Finalize any remaining import state */ // XXX Move these up to where finalize_modules() is currently. _PyImport_FiniCore(tstate->interp); _PyImport_Fini(); + /* Disable tracemalloc after all Python objects have been destroyed, + so it is possible to use tracemalloc in objects destructor. */ + _PyTraceMalloc_Fini(); + /* unload faulthandler module */ _PyFaulthandler_Fini();