[Python-checkins] bpo-42972: Fully implement GC protocol for functools LRU cache (GH-26423)
miss-islington
webhook-mailer at python.org
Fri May 28 10:26:25 EDT 2021
https://github.com/python/cpython/commit/1c0106ca8c72d671ad4e2b553489d786d06fce03
commit: 1c0106ca8c72d671ad4e2b553489d786d06fce03
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-05-28T07:26:07-07:00
summary:
bpo-42972: Fully implement GC protocol for functools LRU cache (GH-26423)
(cherry picked from commit 3f8d33252722750e6c019d3df7ce0fabf7bdd45e)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland at innova.no>
files:
M Modules/_functoolsmodule.c
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index b028f8f0c7aab..218a8d16ac32d 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);
More information about the Python-checkins
mailing list