diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-11-27 18:42:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-27 18:42:48 (GMT) |
commit | 4463d2e01886824ccc7857205f6acb9a3d01d0ab (patch) | |
tree | fc8d8f89a9c41e3484d0f6edb0a18c76bc8b3951 /Modules | |
parent | 46047bb12b4570adc9f81577568669930e12b590 (diff) | |
download | cpython-4463d2e01886824ccc7857205f6acb9a3d01d0ab.zip cpython-4463d2e01886824ccc7857205f6acb9a3d01d0ab.tar.gz cpython-4463d2e01886824ccc7857205f6acb9a3d01d0ab.tar.bz2 |
[3.12] bpo-41422: Visit the Pickler's and Unpickler's memo in tp_traverse (GH-21664) (GH-112464)
(cherry picked from commit 967f2a3052c2d22e31564b428a9aa8cc63dc2a9f)
Co-authored-by: kale-smoothie <34165060+kale-smoothie@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_pickle.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index d2f6d71..2bf9977 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -4712,6 +4712,14 @@ Pickler_traverse(PicklerObject *self, visitproc visit, void *arg) Py_VISIT(self->fast_memo); Py_VISIT(self->reducer_override); Py_VISIT(self->buffer_callback); + PyMemoTable *memo = self->memo; + if (memo && memo->mt_table) { + Py_ssize_t i = memo->mt_allocated; + while (--i >= 0) { + Py_VISIT(memo->mt_table[i].me_key); + } + } + return 0; } @@ -7181,6 +7189,13 @@ Unpickler_traverse(UnpicklerObject *self, visitproc visit, void *arg) Py_VISIT(self->stack); Py_VISIT(self->pers_func); Py_VISIT(self->buffers); + PyObject **memo = self->memo; + if (memo) { + Py_ssize_t i = self->memo_size; + while (--i >= 0) { + Py_VISIT(memo[i]); + } + } return 0; } |