Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed reference leak in the initalization of :mod:`tkinter`.
4 changes: 4 additions & 0 deletions Modules/_tkinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -3421,6 +3421,7 @@ PyInit__tkinter(void)
Tkinter_TclError = PyErr_NewException("_tkinter.TclError", NULL, NULL);
if (PyModule_AddObjectRef(m, "TclError", Tkinter_TclError)) {
Py_DECREF(m);
Py_DECREF(Tkinter_TclError);
return NULL;
}

Expand Down Expand Up @@ -3474,18 +3475,21 @@ PyInit__tkinter(void)
Py_DECREF(m);
return NULL;
}
Py_DECREF(Tkapp_Type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the same for all other global references (otherwise why would they be global references?).

Yes, if you want to release these references, you need a module clearing function. This is not a big deal, because usually when you unload the module, you quit the program, so who cares about few dangling references?


Tktt_Type = PyType_FromSpec(&Tktt_Type_spec);
if (PyModule_AddObjectRef(m, "TkttType", Tktt_Type)) {
Py_DECREF(m);
return NULL;
}
Py_DECREF(Tktt_Type);

PyTclObject_Type = PyType_FromSpec(&PyTclObject_Type_spec);
if (PyModule_AddObjectRef(m, "Tcl_Obj", PyTclObject_Type)) {
Py_DECREF(m);
return NULL;
}
Py_DECREF(PyTclObject_Type);


/* This helps the dynamic loader; in Unicode aware Tcl versions
Expand Down