File tree Expand file tree Collapse file tree 4 files changed +8
-6
lines changed
Misc/NEWS.d/next/Core_and_Builtins Expand file tree Collapse file tree 4 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -29,8 +29,11 @@ extern "C" {
29
29
PyMutex_LockFlags(wr->weakrefs_lock, _Py_LOCK_DONT_DETACH)
30
30
#define UNLOCK_WEAKREFS_FOR_WR (wr ) PyMutex_Unlock(wr->weakrefs_lock)
31
31
32
- #define FT_CLEAR_WEAKREFS (obj , weakref_list ) \
33
- PyObject_ClearWeakRefs(obj)
32
+ #define FT_CLEAR_WEAKREFS (obj , weakref_list ) \
33
+ do { \
34
+ assert(Py_REFCNT(obj) == 0); \
35
+ PyObject_ClearWeakRefs(obj); \
36
+ } while (0)
34
37
35
38
#else
36
39
Original file line number Diff line number Diff line change 1
- Fix potential :mod: `weakref ` races on objects dealloc on the :term: `free threaded <free
1
+ Fix potential :mod: `weakref ` races in an object's destructor on the :term: `free threaded <free
2
2
threading> ` build.
Original file line number Diff line number Diff line change @@ -737,8 +737,7 @@ pattern_dealloc(PyObject *self)
737
737
{
738
738
PyTypeObject * tp = Py_TYPE (self );
739
739
PyObject_GC_UnTrack (self );
740
- PatternObject * obj = _PatternObject_CAST (self );
741
- FT_CLEAR_WEAKREFS (self , obj -> weakreflist );
740
+ FT_CLEAR_WEAKREFS (self , _PatternObject_CAST (self )-> weakreflist );
742
741
(void )pattern_clear (self );
743
742
tp -> tp_free (self );
744
743
Py_DECREF (tp );
Original file line number Diff line number Diff line change @@ -1365,7 +1365,7 @@ static void
1365
1365
localdummy_dealloc (PyObject * op )
1366
1366
{
1367
1367
localdummyobject * self = localdummyobject_CAST (op );
1368
- PyObject_ClearWeakRefs (op );
1368
+ FT_CLEAR_WEAKREFS (op , self -> weakreflist );
1369
1369
PyTypeObject * tp = Py_TYPE (self );
1370
1370
tp -> tp_free (self );
1371
1371
Py_DECREF (tp );
You can’t perform that action at this time.
0 commit comments