]> granicus.if.org Git - python/commitdiff
bpo-36356: pymain_free() calls _PyRuntime_Finalize() (GH-12435)
authorVictor Stinner <vstinner@redhat.com>
Tue, 19 Mar 2019 13:53:58 +0000 (14:53 +0100)
committerGitHub <noreply@github.com>
Tue, 19 Mar 2019 13:53:58 +0000 (14:53 +0100)
Ensure that _PyRuntime_Finalize() is always call. This change fix a
few memory leaks when running "python3 -V".

Include/internal/pycore_pystate.h
Modules/main.c

index 703a85b96b4e380e554e1d21ae232cc8e630a0b2..7c9d11aec36cfa004dd279912ae68d0ace8832de 100644 (file)
@@ -184,6 +184,8 @@ PyAPI_FUNC(void) _PyRuntimeState_ReInitThreads(void);
    Return NULL on success, or return an error message on failure. */
 PyAPI_FUNC(_PyInitError) _PyRuntime_Initialize(void);
 
+PyAPI_FUNC(void) _PyRuntime_Finalize(void);
+
 #define _Py_CURRENTLY_FINALIZING(tstate) \
     (_PyRuntime.finalizing == tstate)
 
index 8f7a1bfa8308b994bbb4a07a73da03ad561acb95..99396b73c65040620c80eb8ed1c754aaef9ec886 100644 (file)
@@ -839,6 +839,7 @@ pymain_free(void)
     _PyPathConfig_ClearGlobal();
     _Py_ClearStandardStreamEncoding();
     _Py_ClearArgcArgv();
+    _PyRuntime_Finalize();
 }