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

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Xuanteng Huang 2025-06-30 19:14:31 +08:00 committed by GitHub
parent 0533c1faf2
commit b1056c2a44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 77 additions and 83 deletions

View file

@ -5,6 +5,7 @@
#include "pycore_moduleobject.h" // _PyModule_GetState()
#include "pycore_pyatomic_ft_wrappers.h"
#include "pycore_typeobject.h" // _PyType_GetModuleState()
#include "pycore_weakref.h" // FT_CLEAR_WEAKREFS()
#include <stddef.h>
@ -1532,9 +1533,7 @@ deque_dealloc(PyObject *self)
Py_ssize_t i;
PyObject_GC_UnTrack(deque);
if (deque->weakreflist != NULL) {
PyObject_ClearWeakRefs(self);
}
FT_CLEAR_WEAKREFS(self, deque->weakreflist);
if (deque->leftblock != NULL) {
(void)deque_clear(self);
assert(deque->leftblock != NULL);