implement tp_clear

This commit is contained in:
Benjamin Peterson 2011-04-05 17:25:14 -05:00
parent e21a596d51
commit 3bd9729dc9
1 changed files with 10 additions and 1 deletions

View File

@ -355,6 +355,15 @@ keyobject_traverse(keyobject *ko, visitproc visit, void *arg)
return 0;
}
static int
keyobject_clear(keyobject *ko)
{
Py_CLEAR(ko->cmp);
if (ko->object)
Py_CLEAR(ko->object);
return 0;
}
static PyMemberDef keyobject_members[] = {
{"obj", T_OBJECT,
offsetof(keyobject, object), 0,
@ -392,7 +401,7 @@ static PyTypeObject keyobject_type = {
Py_TPFLAGS_DEFAULT, /* tp_flags */
0, /* tp_doc */
(traverseproc)keyobject_traverse, /* tp_traverse */
0, /* tp_clear */
(inquiry)keyobject_clear, /* tp_clear */
keyobject_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */