mirror of
https://github.com/python/cpython.git
synced 2025-12-22 16:39:14 +00:00
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:
parent
0533c1faf2
commit
b1056c2a44
32 changed files with 77 additions and 83 deletions
|
|
@ -29,6 +29,12 @@ extern "C" {
|
|||
PyMutex_LockFlags(wr->weakrefs_lock, _Py_LOCK_DONT_DETACH)
|
||||
#define UNLOCK_WEAKREFS_FOR_WR(wr) PyMutex_Unlock(wr->weakrefs_lock)
|
||||
|
||||
#define FT_CLEAR_WEAKREFS(obj, weakref_list) \
|
||||
do { \
|
||||
assert(Py_REFCNT(obj) == 0); \
|
||||
PyObject_ClearWeakRefs(obj); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define LOCK_WEAKREFS(obj)
|
||||
|
|
@ -37,6 +43,14 @@ extern "C" {
|
|||
#define LOCK_WEAKREFS_FOR_WR(wr)
|
||||
#define UNLOCK_WEAKREFS_FOR_WR(wr)
|
||||
|
||||
#define FT_CLEAR_WEAKREFS(obj, weakref_list) \
|
||||
do { \
|
||||
assert(Py_REFCNT(obj) == 0); \
|
||||
if (weakref_list != NULL) { \
|
||||
PyObject_ClearWeakRefs(obj); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
static inline int _is_dead(PyObject *obj)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue