Skip to content

Commit 168fe43

Browse files
committed
keep the necessary bits
1 parent 022d71e commit 168fe43

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Modules/_tkinter.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,14 @@ Tkapp_New(const char *screenName, const char *className,
589589
int interactive, int wantobjects, int wantTk, int sync,
590590
const char *use)
591591
{
592+
PyTypeObject *type;
592593
TkappObject *v;
593594
char *argv0;
594595

595-
v = PyObject_New(TkappObject, (PyTypeObject *) Tkapp_Type);
596+
type = (PyTypeObject *)Tkapp_Type;
597+
assert(type != NULL);
598+
assert(type->tp_alloc != NULL);
599+
v = (TkappObject *)type->tp_alloc(type, 0);
596600
if (v == NULL)
597601
return NULL;
598602

@@ -2771,10 +2775,9 @@ static void
27712775
Tktt_Dealloc(PyObject *op)
27722776
{
27732777
PyTypeObject *tp = Py_TYPE(op);
2774-
printf("%p\n", ((TkttObject *)op)->func);
27752778
PyObject_GC_UnTrack(op);
27762779
TkttObject *self = TkttObject_CAST(op);
2777-
Py_XDECREF(self->func);
2780+
(void)Tktt_Clear(op);
27782781
tp->tp_free(op);
27792782
Py_DECREF(tp);
27802783
}
@@ -3096,7 +3099,7 @@ Tkapp_Dealloc(PyObject *op)
30963099
ENTER_TCL
30973100
Tcl_DeleteInterp(Tkapp_Interp(self));
30983101
LEAVE_TCL
3099-
Py_XDECREF(self->trace);
3102+
(void)Tkapp_Clear(op);
31003103
tp->tp_free(self);
31013104
Py_DECREF(tp);
31023105
DisableEventHook();
@@ -3297,7 +3300,7 @@ static PyMethodDef Tktt_methods[] =
32973300
};
32983301

32993302
static PyType_Slot Tktt_Type_slots[] = {
3300-
// {Py_tp_clear, Tktt_Clear},
3303+
{Py_tp_clear, Tktt_Clear},
33013304
{Py_tp_dealloc, Tktt_Dealloc},
33023305
{Py_tp_traverse, Tktt_Traverse},
33033306
{Py_tp_repr, Tktt_Repr},
@@ -3358,7 +3361,7 @@ static PyMethodDef Tkapp_methods[] =
33583361
};
33593362

33603363
static PyType_Slot Tkapp_Type_slots[] = {
3361-
// {Py_tp_clear, Tkapp_Clear},
3364+
{Py_tp_clear, Tkapp_Clear},
33623365
{Py_tp_dealloc, Tkapp_Dealloc},
33633366
{Py_tp_traverse, Tkapp_Traverse},
33643367
{Py_tp_methods, Tkapp_methods},

0 commit comments

Comments
 (0)