@@ -34,6 +34,13 @@ class _queue.SimpleQueue "simplequeueobject *" "simplequeue_get_state_by_type(ty
3434[clinic start generated code]*/
3535/*[clinic end generated code: output=da39a3ee5e6b4b0d input=0a4023fe4d198c8d]*/
3636
37+ static int
38+ simplequeue_clear (simplequeueobject * self )
39+ {
40+ Py_CLEAR (self -> lst );
41+ return 0 ;
42+ }
43+
3744static void
3845simplequeue_dealloc (simplequeueobject * self )
3946{
@@ -46,7 +53,7 @@ simplequeue_dealloc(simplequeueobject *self)
4653 PyThread_release_lock (self -> lock );
4754 PyThread_free_lock (self -> lock );
4855 }
49- Py_XDECREF ( self -> lst );
56+ ( void ) simplequeue_clear ( self );
5057 if (self -> weakreflist != NULL )
5158 PyObject_ClearWeakRefs ((PyObject * ) self );
5259 Py_TYPE (self )-> tp_free (self );
@@ -57,6 +64,7 @@ static int
5764simplequeue_traverse (simplequeueobject * self , visitproc visit , void * arg )
5865{
5966 Py_VISIT (self -> lst );
67+ Py_VISIT (Py_TYPE (self ));
6068 return 0 ;
6169}
6270
@@ -362,6 +370,7 @@ static PyType_Slot simplequeue_slots[] = {
362370 {Py_tp_dealloc , simplequeue_dealloc },
363371 {Py_tp_doc , (void * )simplequeue_new__doc__ },
364372 {Py_tp_traverse , simplequeue_traverse },
373+ {Py_tp_clear , simplequeue_clear },
365374 {Py_tp_members , simplequeue_members },
366375 {Py_tp_methods , simplequeue_methods },
367376 {Py_tp_new , simplequeue_new },
0 commit comments