Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Next Next commit
Switch to a module clear function.
  • Loading branch information
ZeroIntensity committed Aug 30, 2024
commit cc291e4cdc3801f2f9592b4061570201c217cf4e
15 changes: 9 additions & 6 deletions Modules/_tkinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -3389,6 +3389,14 @@ DisableEventHook(void)
#endif
}

static void
module_free(void *mod)
{
Py_DECREF(Tkinter_TclError);
Py_DECREF(Tkapp_Type);
Py_DECREF(Tktt_Type);
Py_DECREF(PyTclObject_Type);
Comment thread
ZeroIntensity marked this conversation as resolved.
Outdated
}

static struct PyModuleDef _tkintermodule = {
PyModuleDef_HEAD_INIT,
Expand All @@ -3399,7 +3407,7 @@ static struct PyModuleDef _tkintermodule = {
NULL,
NULL,
NULL,
NULL
module_free
Comment thread
ZeroIntensity marked this conversation as resolved.
Outdated
};

PyMODINIT_FUNC
Expand All @@ -3421,7 +3429,6 @@ 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 @@ -3475,22 +3482,18 @@ PyInit__tkinter(void)
Py_DECREF(m);
return NULL;
}
Py_DECREF(Tkapp_Type);

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
it also helps Tcl find its encodings. */
Expand Down