https://github.com/python/cpython/commit/a8bc03696c7c2c03e1d580633151ec7b850366f3
commit: a8bc03696c7c2c03e1d580633151ec7b850366f3
branch: main
author: Peter Bierma <[email protected]>
committer: vstinner <[email protected]>
date: 2024-09-03T20:35:57Z
summary:
gh-123504: Fix reference leak in finalization of `_tkinter` (#123505)
files:
A Misc/NEWS.d/next/Library/2024-08-30-09-01-35.gh-issue-123504.lJ9_BB.rst
M Modules/_tkinter.c
diff --git
a/Misc/NEWS.d/next/Library/2024-08-30-09-01-35.gh-issue-123504.lJ9_BB.rst
b/Misc/NEWS.d/next/Library/2024-08-30-09-01-35.gh-issue-123504.lJ9_BB.rst
new file mode 100644
index 00000000000000..ea504d3532dc44
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-08-30-09-01-35.gh-issue-123504.lJ9_BB.rst
@@ -0,0 +1 @@
+Fixed reference leak in the finalization of :mod:`tkinter`.
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 1542d3af42f755..e1e81082d9ec47 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -3389,17 +3389,28 @@ DisableEventHook(void)
#endif
}
+static int
+module_clear(PyObject *mod)
+{
+ Py_CLEAR(Tkinter_TclError);
+ Py_CLEAR(Tkapp_Type);
+ Py_CLEAR(Tktt_Type);
+ Py_CLEAR(PyTclObject_Type);
+ return 0;
+}
+
+static void
+module_free(void *mod)
+{
+ module_clear((PyObject *)mod);
+}
static struct PyModuleDef _tkintermodule = {
PyModuleDef_HEAD_INIT,
- "_tkinter",
- NULL,
- -1,
- moduleMethods,
- NULL,
- NULL,
- NULL,
- NULL
+ .m_name = "_tkinter",
+ .m_methods = moduleMethods,
+ .m_clear = module_clear,
+ .m_free = module_free
};
PyMODINIT_FUNC
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]