Skip to content
Merged
Changes from 1 commit
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
33 changes: 25 additions & 8 deletions Modules/_curses_panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,11 @@ static PyObject *
PyCursesPanel_New(_curses_panel_state *state, PANEL *pan,
PyCursesWindowObject *wo)
{
PyCursesPanelObject *po = PyObject_New(PyCursesPanelObject,
state->PyCursesPanel_Type);
assert(state != NULL);
PyTypeObject *type = state->PyCursesPanel_Type;
assert(type != NULL);
assert(type->tp_alloc != NULL);
PyCursesPanelObject *po = (PyCursesPanelObject *)type->tp_alloc(type, 0);
if (po == NULL) {
return NULL;
}
Expand All @@ -429,11 +432,11 @@ PyCursesPanel_New(_curses_panel_state *state, PANEL *pan,
static void
PyCursesPanel_Dealloc(PyObject *self)
{
PyObject *tp, *obj;
PyCursesPanelObject *po = _PyCursesPanelObject_CAST(self);
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);

tp = (PyObject *) Py_TYPE(po);
obj = (PyObject *) panel_userptr(po->pan);
PyCursesPanelObject *po = _PyCursesPanelObject_CAST(self);
PyObject *obj = (PyObject *)panel_userptr(po->pan);
if (obj) {
Py_DECREF(obj);
if (set_panel_userptr(po->pan, NULL) == ERR) {
Expand All @@ -452,10 +455,19 @@ PyCursesPanel_Dealloc(PyObject *self)
PyErr_FormatUnraisable("Exception ignored in PyCursesPanel_Dealloc()");
}
}
PyObject_Free(po);
tp->tp_free(po);
Py_DECREF(tp);
}

static int
PyCursesPanel_Traverse(PyObject *op, visitproc visit, void *arg)
{
PyCursesPanelObject *self = _PyCursesPanelObject_CAST(op);
Py_VISIT(Py_TYPE(op));
Py_VISIT(self->wo);
return 0;
}

/* panel_above(NULL) returns the bottom panel in the stack. To get
this behaviour we use curses.panel.bottom_panel(). */
/*[clinic input]
Expand Down Expand Up @@ -648,14 +660,19 @@ static PyMethodDef PyCursesPanel_Methods[] = {

static PyType_Slot PyCursesPanel_Type_slots[] = {
{Py_tp_dealloc, PyCursesPanel_Dealloc},
{Py_tp_traverse, PyCursesPanel_Traverse},
{Py_tp_methods, PyCursesPanel_Methods},
{0, 0},
};

static PyType_Spec PyCursesPanel_Type_spec = {
.name = "_curses_panel.panel",
.basicsize = sizeof(PyCursesPanelObject),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION,
.flags = (
Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_DISALLOW_INSTANTIATION
| Py_TPFLAGS_HAVE_GC
),
.slots = PyCursesPanel_Type_slots
};

Expand Down
Loading