]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Replace _PyGC_REFS macros with higher level macros (GH-6852)
authorINADA Naoki <methane@users.noreply.github.com>
Thu, 17 May 2018 02:07:21 +0000 (11:07 +0900)
committerGitHub <noreply@github.com>
Thu, 17 May 2018 02:07:21 +0000 (11:07 +0900)
Only gcmodule.c uses _PyGC_REFS* macros now.
This makes easy to read GC code.

Modules/_testcapimodule.c
Objects/object.c

index 0e48463976e4d2262b59365881bd241345a4fbe2..3086aab4063d427f20f656d075ec695559d0377f 100644 (file)
@@ -3215,8 +3215,7 @@ slot_tp_del(PyObject *self)
         _Py_NewReference(self);
         self->ob_refcnt = refcnt;
     }
-    assert(!PyType_IS_GC(Py_TYPE(self)) ||
-           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
+    assert(!PyType_IS_GC(Py_TYPE(self)) || _PyObject_GC_IS_TRACKED(self));
     /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
      * we need to undo that. */
     _Py_DEC_REFTOTAL;
index 6532c3b287e74365562b252ea061bf83bc8374c9..3eb4810bd9acb4bb36031e944523fda4b8802668 100644 (file)
@@ -316,9 +316,7 @@ PyObject_CallFinalizerFromDealloc(PyObject *self)
     _Py_NewReference(self);
     self->ob_refcnt = refcnt;
 
-    if (PyType_IS_GC(Py_TYPE(self))) {
-        assert(_PyGC_REFS(self) != _PyGC_REFS_UNTRACKED);
-    }
+    assert(!PyType_IS_GC(Py_TYPE(self)) || _PyObject_GC_IS_TRACKED(self));
     /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
      * we need to undo that. */
     _Py_DEC_REFTOTAL;
@@ -2095,7 +2093,7 @@ void
 _PyTrash_deposit_object(PyObject *op)
 {
     assert(PyObject_IS_GC(op));
-    assert(_PyGC_REFS(op) == _PyGC_REFS_UNTRACKED);
+    assert(!_PyObject_GC_IS_TRACKED(op));
     assert(op->ob_refcnt == 0);
     _Py_AS_GC(op)->gc.gc_prev = (PyGC_Head *)_PyRuntime.gc.trash_delete_later;
     _PyRuntime.gc.trash_delete_later = op;
@@ -2107,7 +2105,7 @@ _PyTrash_thread_deposit_object(PyObject *op)
 {
     PyThreadState *tstate = PyThreadState_GET();
     assert(PyObject_IS_GC(op));
-    assert(_PyGC_REFS(op) == _PyGC_REFS_UNTRACKED);
+    assert(!_PyObject_GC_IS_TRACKED(op));
     assert(op->ob_refcnt == 0);
     _Py_AS_GC(op)->gc.gc_prev = (PyGC_Head *) tstate->trash_delete_later;
     tstate->trash_delete_later = op;