[Python-checkins] bpo-36356: pymain_free() calls _PyRuntime_Finalize() (GH-12435)

Victor Stinner webhook-mailer at python.org
Tue Mar 19 09:54:02 EDT 2019


https://github.com/python/cpython/commit/f5f336a819a3d881bb217bf8f9b5cacba03a4e45
commit: f5f336a819a3d881bb217bf8f9b5cacba03a4e45
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2019-03-19T14:53:58+01:00
summary:

bpo-36356: pymain_free() calls _PyRuntime_Finalize() (GH-12435)

Ensure that _PyRuntime_Finalize() is always call. This change fix a
few memory leaks when running "python3 -V".

files:
M Include/internal/pycore_pystate.h
M Modules/main.c

diff --git a/Include/internal/pycore_pystate.h b/Include/internal/pycore_pystate.h
index 703a85b96b4e..7c9d11aec36c 100644
--- a/Include/internal/pycore_pystate.h
+++ b/Include/internal/pycore_pystate.h
@@ -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)
 
diff --git a/Modules/main.c b/Modules/main.c
index 8f7a1bfa8308..99396b73c650 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -839,6 +839,7 @@ pymain_free(void)
     _PyPathConfig_ClearGlobal();
     _Py_ClearStandardStreamEncoding();
     _Py_ClearArgcArgv();
+    _PyRuntime_Finalize();
 }
 
 



More information about the Python-checkins mailing list