8000 bpo-42972: Fully implement GC protocol for functools LRU cache · python/cpython@3573c4d · GitHub
[go: up one dir, main page]

Skip to content

Commit 3573c4d

Browse files
author
Erlend E. Aasland
committed
bpo-42972: Fully implement GC protocol for functools LRU cache
1 parent fba42d1 commit 3573c4d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Modules/_functoolsmodule.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,8 +1240,8 @@ static int
12401240
lru_cache_tp_clear(lru_cache_object *self)
12411241
{
12421242
lru_list_elem *list = lru_cache_unlink_list(self);
1243-
Py_CLEAR(self->func);
12441243
Py_CLEAR(self->cache);
1244+
Py_CLEAR(self->func);
12451245
Py_CLEAR(self->kwd_mark);
12461246
Py_CLEAR(self->lru_list_elem_type);
12471247
Py_CLEAR(self->cache_info_type);
@@ -1327,15 +1327,17 @@ lru_cache_deepcopy(PyObject *self, PyObject *unused)
13271327
static int
13281328
lru_cache_tp_traverse(lru_cache_object *self, visitproc visit, void *arg)
13291329
{
1330+
Py_VISIT(Py_TYPE(self));
13301331
lru_list_elem *link = self->root.next;
13311332
while (link != &self->root) {
13321333
lru_list_elem *next = link->next;
13331334
Py_VISIT(link->key);
13341335
Py_VISIT(link->result);
1336+
Py_VISIT(Py_TYPE(link));
13351337
link = next;
13361338
}
1337-
Py_VISIT(self->func);
13381339
Py_VISIT(self->cache);
1340+
Py_VISIT(self->func);
13391341
Py_VISIT(self->kwd_mark);
13401342
Py_VISIT(self->lru_list_elem_type);
13411343
Py_VISIT(self->cache_info_type);

0 commit comments

Comments
 (0)
0