[Python-checkins] cpython: Issue #19972: Add rarely used freefunc. This fixes a leak if sys.exit()
stefan.krah
python-checkins at python.org
Sat Dec 14 13:44:00 CET 2013
http://hg.python.org/cpython/rev/8a78988fdb04
changeset: 87951:8a78988fdb04
user: Stefan Krah <skrah at bytereef.org>
date: Sat Dec 14 13:43:10 2013 +0100
summary:
Issue #19972: Add rarely used freefunc. This fixes a leak if sys.exit()
is used in a program.
files:
Modules/_pickle.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -7464,6 +7464,12 @@
return 0;
}
+static void
+pickle_free(PyObject *m)
+{
+ _Pickle_ClearState(_Pickle_GetState(m));
+}
+
static int
pickle_traverse(PyObject *m, visitproc visit, void *arg)
{
@@ -7485,14 +7491,14 @@
static struct PyModuleDef _picklemodule = {
PyModuleDef_HEAD_INIT,
- "_pickle", /* m_name */
- pickle_module_doc, /* m_doc */
- sizeof(PickleState), /* m_size */
- pickle_methods, /* m_methods */
- NULL, /* m_reload */
- pickle_traverse, /* m_traverse */
- pickle_clear, /* m_clear */
- NULL /* m_free */
+ "_pickle", /* m_name */
+ pickle_module_doc, /* m_doc */
+ sizeof(PickleState), /* m_size */
+ pickle_methods, /* m_methods */
+ NULL, /* m_reload */
+ pickle_traverse, /* m_traverse */
+ pickle_clear, /* m_clear */
+ (freefunc)pickle_free /* m_free */
};
PyMODINIT_FUNC
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list