[Python-checkins] bpo-36356: pymain_free() calls _PyRuntime_Finalize() (GH-12436)
Victor Stinner
webhook-mailer at python.org
Tue Mar 19 10:08:23 EDT 2019
https://github.com/python/cpython/commit/935250d6f3ac7ba91e1ea8e6ca63aaf7f605e291
commit: 935250d6f3ac7ba91e1ea8e6ca63aaf7f605e291
branch: 3.7
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2019-03-19T15:08:17+01:00
summary:
bpo-36356: pymain_free() calls _PyRuntime_Finalize() (GH-12436)
Ensure that _PyRuntime_Finalize() is always call. This change fix a
few memory leaks when running "python3 -V".
files:
M Include/internal/pystate.h
M Modules/main.c
diff --git a/Include/internal/pystate.h b/Include/internal/pystate.h
index 721d34fa4c19..5891339b5434 100644
--- a/Include/internal/pystate.h
+++ b/Include/internal/pystate.h
@@ -118,6 +118,9 @@ PyAPI_FUNC(void) _PyRuntimeState_Fini(_PyRuntimeState *);
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 a745381109d3..f94689496a38 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -660,6 +660,8 @@ pymain_free_raw(_PyMain *pymain)
orig_argc = 0;
orig_argv = NULL;
+ _PyRuntime_Finalize();
+
PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
}
More information about the Python-checkins
mailing list