Skip to content

Commit 3f8d332

Browse files
author
Erlend Egeberg Aasland
authored
bpo-42972: Fully implement GC protocol for functools LRU cache (GH-26423)
1 parent f8a95df commit 3f8d332

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Modules/_functoolsmodule.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1255,8 +1255,8 @@ static int
12551255
lru_cache_tp_clear(lru_cache_object *self)
12561256
{
12571257
lru_list_elem *list = lru_cache_unlink_list(self);
1258-
Py_CLEAR(self->func);
12591258
Py_CLEAR(self->cache);
1259+
Py_CLEAR(self->func);
12601260
Py_CLEAR(self->kwd_mark);
12611261
Py_CLEAR(self->lru_list_elem_type);
12621262
Py_CLEAR(self->cache_info_type);
@@ -1342,15 +1342,17 @@ lru_cache_deepcopy(PyObject *self, PyObject *unused)
13421342
static int
13431343
lru_cache_tp_traverse(lru_cache_object *self, visitproc visit, void *arg)
13441344
{
1345+
Py_VISIT(Py_TYPE(self));
13451346
lru_list_elem *link = self->root.next;
13461347
while (link != &self->root) {
13471348
lru_list_elem *next = link->next;
13481349
Py_VISIT(link->key);
13491350
Py_VISIT(link->result);
1351+
Py_VISIT(Py_TYPE(link));
13501352
link = next;
13511353
}
1352-
Py_VISIT(self->func);
13531354
Py_VISIT(self->cache);
1355+
Py_VISIT(self->func);
13541356
Py_VISIT(self->kwd_mark);
13551357
Py_VISIT(self->lru_list_elem_type);
13561358
Py_VISIT(self->cache_info_type);

0 commit comments

Comments
 (0)