@@ -763,20 +763,10 @@ typedef struct lru_list_elem {
763763 PyObject * key , * result ;
764764} lru_list_elem ;
765765
766- static int
767- lru_list_elem_traverse (lru_list_elem * link , visitproc visit , void * arg )
768- {
769- Py_VISIT (link -> key );
770- Py_VISIT (link -> result );
771- Py_VISIT (Py_TYPE (link ));
772- return 0 ;
773- }
774-
775766static void
776767lru_list_elem_dealloc (lru_list_elem * link )
777768{
778769 PyTypeObject * tp = Py_TYPE (link );
779- PyObject_GC_UnTrack (link );
780770 Py_XDECREF (link -> key );
781771 Py_XDECREF (link -> result );
782772 tp -> tp_free (link );
@@ -785,15 +775,13 @@ lru_list_elem_dealloc(lru_list_elem *link)
785775
786776static PyType_Slot lru_list_elem_type_slots [] = {
787777 {Py_tp_dealloc , lru_list_elem_dealloc },
788- {Py_tp_traverse , lru_list_elem_traverse },
789778 {0 , 0 }
790779};
791780
792781static PyType_Spec lru_list_elem_type_spec = {
793782 .name = "functools._lru_list_elem" ,
794783 .basicsize = sizeof (lru_list_elem ),
795- .flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION |
796- Py_TPFLAGS_HAVE_GC ),
784+ .flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION ,
797785 .slots = lru_list_elem_type_slots
798786};
799787
@@ -1058,8 +1046,8 @@ bounded_lru_cache_wrapper(lru_cache_object *self, PyObject *args, PyObject *kwds
10581046 self -> root .next == & self -> root )
10591047 {
10601048 /* Cache is not full, so put the result in a new link */
1061- link = (lru_list_elem * )PyObject_GC_New (lru_list_elem ,
1062- self -> lru_list_elem_type );
1049+ link = (lru_list_elem * )PyObject_New (lru_list_elem ,
1050+ self -> lru_list_elem_type );
10631051 if (link == NULL ) {
10641052 Py_DECREF (key );
10651053 Py_DECREF (result );
@@ -1069,7 +1057,6 @@ bounded_lru_cache_wrapper(lru_cache_object *self, PyObject *args, PyObject *kwds
10691057 link -> hash = hash ;
10701058 link -> key = key ;
10711059 link -> result = result ;
1072- PyObject_GC_Track (link );
10731060 /* What is really needed here is a SetItem variant with a "no clobber"
10741061 option. If the __eq__ call triggers a reentrant call that adds
10751062 this same key, then this setitem call will update the cache dict
@@ -1359,7 +1346,9 @@ lru_cache_tp_traverse(lru_cache_object *self, visitproc visit, void *arg)
13591346 lru_list_elem * link = self -> root .next ;
13601347 while (link != & self -> root ) {
13611348 lru_list_elem * next = link -> next ;
1362- Py_VISIT (link );
1349+ Py_VISIT (link -> key );
1350+ Py_VISIT (link -> result );
1351+ Py_VISIT (Py_TYPE (link ));
13631352 link = next ;
13641353 }
13651354 Py_VISIT (self -> cache );
0 commit comments