Skip to content

Commit

Permalink
bpo-42972: Fully implement GC protocol for xxlimited (GH-26451)
Browse files Browse the repository at this point in the history
  • Loading branch information
shihai1991 committed May 31, 2021
1 parent 8ab5b7e commit 4b20f25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Modules/xxlimited.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ Xxo_traverse(XxoObject *self, visitproc visit, void *arg)
return 0;
}

static int
Xxo_clear(XxoObject *self)
{
Py_CLEAR(self->x_attr);
return 0;
}

static void
Xxo_finalize(XxoObject *self)
{
Expand Down Expand Up @@ -214,6 +221,7 @@ PyDoc_STRVAR(Xxo_doc,
static PyType_Slot Xxo_Type_slots[] = {
{Py_tp_doc, (char *)Xxo_doc},
{Py_tp_traverse, Xxo_traverse},
{Py_tp_clear, Xxo_clear},
{Py_tp_finalize, Xxo_finalize},
{Py_tp_dealloc, Xxo_dealloc},
{Py_tp_getattro, Xxo_getattro},
Expand Down
8 changes: 8 additions & 0 deletions Modules/xxlimited_35.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ Xxo_traverse(XxoObject *self, visitproc visit, void *arg)
return 0;
}

static int
Xxo_clear(XxoObject *self)
{
Py_CLEAR(self->x_attr);
return 0;
}

static void
Xxo_finalize(XxoObject *self)
{
Expand Down Expand Up @@ -108,6 +115,7 @@ Xxo_setattr(XxoObject *self, const char *name, PyObject *v)
static PyType_Slot Xxo_Type_slots[] = {
{Py_tp_doc, "The Xxo type"},
{Py_tp_traverse, Xxo_traverse},
{Py_tp_clear, Xxo_clear},
{Py_tp_finalize, Xxo_finalize},
{Py_tp_getattro, Xxo_getattro},
{Py_tp_setattr, Xxo_setattr},
Expand Down

0 comments on commit 4b20f25

Please sign in to comment.