https://github.com/python/cpython/commit/2fcad2a47beef88937e1a8f3adba813a33cb31fe
commit: 2fcad2a47beef88937e1a8f3adba813a33cb31fe
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: sobolevn <[email protected]>
date: 2025-02-16T14:22:23Z
summary:

[3.13] gh-130179: Fix `persistent_{id,load}_attr` reference leaks in `_pickle` 
(GH-130180) (#130190)

gh-130179: Fix `persistent_{id,load}_attr` reference leaks in `_pickle` 
(GH-130180)
(cherry picked from commit e7f00cd14f6a0c0dee6e733ac3e2c5d92e0809bb)

Co-authored-by: Sergey Miryanov <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>

files:
M Modules/_pickle.c

diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 9bb3947e0967a4..83c4ba6087e620 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -4652,6 +4652,7 @@ Pickler_clear(PicklerObject *self)
     Py_CLEAR(self->output_buffer);
     Py_CLEAR(self->write);
     Py_CLEAR(self->persistent_id);
+    Py_CLEAR(self->persistent_id_attr);
     Py_CLEAR(self->dispatch_table);
     Py_CLEAR(self->fast_memo);
     Py_CLEAR(self->reducer_override);
@@ -4681,6 +4682,7 @@ Pickler_traverse(PicklerObject *self, visitproc visit, 
void *arg)
     Py_VISIT(Py_TYPE(self));
     Py_VISIT(self->write);
     Py_VISIT(self->persistent_id);
+    Py_VISIT(self->persistent_id_attr);
     Py_VISIT(self->dispatch_table);
     Py_VISIT(self->fast_memo);
     Py_VISIT(self->reducer_override);
@@ -7138,6 +7140,7 @@ Unpickler_clear(UnpicklerObject *self)
     Py_CLEAR(self->peek);
     Py_CLEAR(self->stack);
     Py_CLEAR(self->persistent_load);
+    Py_CLEAR(self->persistent_load_attr);
     Py_CLEAR(self->buffers);
     if (self->buffer.buf != NULL) {
         PyBuffer_Release(&self->buffer);
@@ -7177,6 +7180,7 @@ Unpickler_traverse(UnpicklerObject *self, visitproc 
visit, void *arg)
     Py_VISIT(self->peek);
     Py_VISIT(self->stack);
     Py_VISIT(self->persistent_load);
+    Py_VISIT(self->persistent_load_attr);
     Py_VISIT(self->buffers);
     PyObject **memo = self->memo;
     if (memo) {

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to