8000 bpo-42972: Fully implement GC protocol for xxlimited (GH-26451) (GH-2… · python/cpython@f097d23 · GitHub
[go: up one dir, main page]

Skip to content

Commit f097d23

Browse files
bpo-42972: Fully implement GC protocol for xxlimited (GH-26451) (GH-26460)
(cherry picked from commit 4b20f25) Co-authored-by: Hai Shi <shihai1992@gmail.com> Co-authored-by: Hai Shi <shihai1992@gmail.com>
1 parent ff359d7 commit f097d23

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Modules/xxlimited.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ Xxo_traverse(XxoObject *self, visitproc visit, void *arg)
106106
return 0;
107107
}
108108

109+
static int
110+
Xxo_clear(XxoObject *self)
111+
{
112+
Py_CLEAR(self->x_attr);
113+
return 0;
114+
}
115+
109116
static void
110117
Xxo_finalize(XxoObject *self)
111118
{
@@ -214,6 +221,7 @@ PyDoc_STRVAR(Xxo_doc,
214221
static PyType_Slot Xxo_Type_slots[] = {
215222
{Py_tp_doc, (char *)Xxo_doc},
216223
{Py_tp_traverse, Xxo_traverse},
224+
{Py_tp_clear, Xxo_clear},
217225
{Py_tp_finalize, Xxo_finalize},
218226
{Py_tp_dealloc, Xxo_dealloc},
219227
{Py_tp_getattro, Xxo_getattro},

Modules/xxlimited_35.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ Xxo_traverse(XxoObject *self, visitproc visit, void *arg)
4343
return 0;
4444
}
4545

46+
static int
47+
Xxo_clear(XxoObject *self)
48+
{
49+
Py_CLEAR(self->x_attr);
50+
return 0;
51+
}
52+
4653
static void
4754
Xxo_finalize(XxoObject *self)
4855
{
@@ -108,6 +115,7 @@ Xxo_setattr(XxoObject *self, const char *name, PyObject *v)
108115
static PyType_Slot Xxo_Type_slots[] = {
109116
{Py_tp_doc, "The Xxo type"},
110117
{Py_tp_traverse, Xxo_traverse},
118+
{Py_tp_clear, Xxo_clear},
111119
{Py_tp_finalize, Xxo_finalize},
112120
{Py_tp_getattro, Xxo_getattro},
113121
{Py_tp_setattr, Xxo_setattr},

0 commit comments

Comments
 (0)
0