bpo-42972: Fully implement GC protocol for xxlimited (GH-26451)

This commit is contained in:
Hai Shi 2021-05-31 15:51:19 +08:00 committed by GitHub
parent 8ab5b7eeca
commit 4b20f2574d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -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)
{
@ -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},

View file

@ -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)
{
@ -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},