[3.14] gh-135607: remove null checking of weakref list in dealloc of extension modules and objects (#135614) (#136119)

gh-135607: remove null checking of weakref list in dealloc of extension modules and objects (#135614)

(cherry picked from commit b1056c2a44)

Co-authored-by: Xuanteng Huang <44627253+xuantengh@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
Victor Stinner 2025-06-30 15:59:22 +02:00 committed by GitHub
parent 729b6747e9
commit 3267847759
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 77 additions and 83 deletions

View file

@ -1,6 +1,7 @@
/* PickleBuffer object implementation */
#include "Python.h"
#include "pycore_weakref.h" // FT_CLEAR_WEAKREFS()
#include <stddef.h>
typedef struct {
@ -111,8 +112,7 @@ picklebuf_dealloc(PyObject *op)
{
PyPickleBufferObject *self = (PyPickleBufferObject*)op;
PyObject_GC_UnTrack(self);
if (self->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
FT_CLEAR_WEAKREFS(op, self->weakreflist);
PyBuffer_Release(&self->view);
Py_TYPE(self)->tp_free((PyObject *) self);
}