@@ -51,13 +51,29 @@ typedef struct {
5151 unsigned long long _abc_negative_cache_version ;
5252} _abc_data ;
5353
54+ static int
55+ abc_data_traverse (_abc_data * self , visitproc visit , void * arg )
56+ {
57+ Py_VISIT (self -> _abc_registry );
58+ Py_VISIT (self -> _abc_cache );
59+ Py_VISIT (self -> _abc_negative_cache );
60+ return 0 ;
61+ }
62+
63+ static int
64+ abc_data_clear (_abc_data * self )
65+ {
66+ Py_CLEAR (self -> _abc_registry );
67+ Py_CLEAR (self -> _abc_cache );
68+ Py_CLEAR (self -> _abc_negative_cache );
69+ return 0 ;
70+ }
71+
5472static void
5573abc_data_dealloc (_abc_data * self )
5674{
5775 PyTypeObject * tp = Py_TYPE (self );
58- Py_XDECREF (self -> _abc_registry );
59- Py_XDECREF (self -> _abc_cache );
60- Py_XDECREF (self -> _abc_negative_cache );
76+ (void )abc_data_clear (self );
6177 tp -> tp_free (self );
6278 Py_DECREF (tp );
6379}
@@ -84,13 +100,15 @@ static PyType_Slot _abc_data_type_spec_slots[] = {
84100 {Py_tp_doc , (void * )abc_data_doc },
85101 {Py_tp_new , abc_data_new },
86102 {Py_tp_dealloc , abc_data_dealloc },
103+ {Py_tp_traverse , abc_data_traverse },
104+ {Py_tp_clear , abc_data_clear },
87105 {0 , 0 }
88106};
89107
90108static PyType_Spec _abc_data_type_spec = {
91109 .name = "_abc._abc_data" ,
92110 .basicsize = sizeof (_abc_data ),
93- .flags = Py_TPFLAGS_DEFAULT ,
111+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC ,
94112 .slots = _abc_data_type_spec_slots ,
95113};
96114
0 commit comments