diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-05-28 09:02:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-28 09:02:42 (GMT) |
commit | 3f8d33252722750e6c019d3df7ce0fabf7bdd45e (patch) | |
tree | a17bbe674756f900465ac828f730ab6058285900 /Modules | |
parent | f8a95df84bcedebc0aa7132b3d1a4e8f000914bc (diff) | |
download | cpython-3f8d33252722750e6c019d3df7ce0fabf7bdd45e.zip cpython-3f8d33252722750e6c019d3df7ce0fabf7bdd45e.tar.gz cpython-3f8d33252722750e6c019d3df7ce0fabf7bdd45e.tar.bz2 |
bpo-42972: Fully implement GC protocol for functools LRU cache (GH-26423)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_functoolsmodule.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index b028f8f..218a8d1 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -1255,8 +1255,8 @@ static int lru_cache_tp_clear(lru_cache_object *self) { lru_list_elem *list = lru_cache_unlink_list(self); - Py_CLEAR(self->func); Py_CLEAR(self->cache); + Py_CLEAR(self->func); Py_CLEAR(self->kwd_mark); Py_CLEAR(self->lru_list_elem_type); Py_CLEAR(self->cache_info_type); @@ -1342,15 +1342,17 @@ lru_cache_deepcopy(PyObject *self, PyObject *unused) static int lru_cache_tp_traverse(lru_cache_object *self, visitproc visit, void *arg) { + Py_VISIT(Py_TYPE(self)); lru_list_elem *link = self->root.next; while (link != &self->root) { lru_list_elem *next = link->next; Py_VISIT(link->key); Py_VISIT(link->result); + Py_VISIT(Py_TYPE(link)); link = next; } - Py_VISIT(self->func); Py_VISIT(self->cache); + Py_VISIT(self->func); Py_VISIT(self->kwd_mark); Py_VISIT(self->lru_list_elem_type); Py_VISIT(self->cache_info_type); |