Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d852142

Browse files
authored
Replace _PyGC_REFS macros with higher level macros (GH-6852)
Only gcmodule.c uses _PyGC_REFS* macros now. This makes easy to read GC code.
1 parent e5f41d2 commit d852142

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

Modules/_testcapimodule.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3215,8 +3215,7 @@ slot_tp_del(PyObject *self)
32153215
_Py_NewReference(self);
32163216
self->ob_refcnt = refcnt;
32173217
}
3218-
assert(!PyType_IS_GC(Py_TYPE(self)) ||
3219-
_Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
3218+
assert(!PyType_IS_GC(Py_TYPE(self)) || _PyObject_GC_IS_TRACKED(self));
32203219
/* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
32213220
* we need to undo that. */
32223221
_Py_DEC_REFTOTAL;

Objects/object.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,7 @@ PyObject_CallFinalizerFromDealloc(PyObject *self)
316316
_Py_NewReference(self);
317317
self->ob_refcnt = refcnt;
318318

319-
if (PyType_IS_GC(Py_TYPE(self))) {
320-
assert(_PyGC_REFS(self) != _PyGC_REFS_UNTRACKED);
321-
}
319+
assert(!PyType_IS_GC(Py_TYPE(self)) || _PyObject_GC_IS_TRACKED(self));
322320
/* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
323321
* we need to undo that. */
324322
_Py_DEC_REFTOTAL;
@@ -2095,7 +2093,7 @@ void
20952093
_PyTrash_deposit_object(PyObject *op)
20962094
{
20972095
assert(PyObject_IS_GC(op));
2098-
assert(_PyGC_REFS(op) == _PyGC_REFS_UNTRACKED);
2096+
assert(!_PyObject_GC_IS_TRACKED(op));
20992097
assert(op->ob_refcnt == 0);
21002098
_Py_AS_GC(op)->gc.gc_prev = (PyGC_Head *)_PyRuntime.gc.trash_delete_later;
21012099
_PyRuntime.gc.trash_delete_later = op;
@@ -2107,7 +2105,7 @@ _PyTrash_thread_deposit_object(PyObject *op)
21072105
{
21082106
PyThreadState *tstate = PyThreadState_GET();
21092107
assert(PyObject_IS_GC(op));
2110-
assert(_PyGC_REFS(op) == _PyGC_REFS_UNTRACKED);
2108+
assert(!_PyObject_GC_IS_TRACKED(op));
21112109
assert(op->ob_refcnt == 0);
21122110
_Py_AS_GC(op)->gc.gc_prev = (PyGC_Head *) tstate->trash_delete_later;
21132111
tstate->trash_delete_later = op;

0 commit comments

Comments
 (0)