bpo-40170: Convert PyObject_IS_GC() macro to a function (GH-19464)
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 281ab33..d2cd2c9 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -442,7 +442,7 @@
{
_PyObject_ASSERT(_PyObject_CAST(parent), !_PyObject_IsFreed(op));
- if (PyObject_IS_GC(op)) {
+ if (_PyObject_IS_GC(op)) {
PyGC_Head *gc = AS_GC(op);
/* We're only interested in gc_refs for objects in the
* generation being collected, which can be recognized
@@ -478,7 +478,7 @@
static int
visit_reachable(PyObject *op, PyGC_Head *reachable)
{
- if (!PyObject_IS_GC(op)) {
+ if (!_PyObject_IS_GC(op)) {
return 0;
}
@@ -705,7 +705,7 @@
static int
visit_move(PyObject *op, PyGC_Head *tolist)
{
- if (PyObject_IS_GC(op)) {
+ if (_PyObject_IS_GC(op)) {
PyGC_Head *gc = AS_GC(op);
if (gc_is_collecting(gc)) {
gc_list_move(gc, tolist);
@@ -1716,7 +1716,7 @@
traverseproc traverse;
PyObject *obj = PyTuple_GET_ITEM(args, i);
- if (! PyObject_IS_GC(obj))
+ if (!_PyObject_IS_GC(obj))
continue;
traverse = Py_TYPE(obj)->tp_traverse;
if (! traverse)
@@ -1856,7 +1856,7 @@
{
PyObject *result;
- if (PyObject_IS_GC(obj) && _PyObject_GC_IS_TRACKED(obj))
+ if (_PyObject_IS_GC(obj) && _PyObject_GC_IS_TRACKED(obj))
result = Py_True;
else
result = Py_False;
@@ -1877,7 +1877,7 @@
gc_is_finalized(PyObject *module, PyObject *obj)
/*[clinic end generated code: output=e1516ac119a918ed input=201d0c58f69ae390]*/
{
- if (PyObject_IS_GC(obj) && _PyGCHead_FINALIZED(AS_GC(obj))) {
+ if (_PyObject_IS_GC(obj) && _PyGCHead_FINALIZED(AS_GC(obj))) {
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
@@ -2204,6 +2204,12 @@
}
}
+int
+PyObject_IS_GC(PyObject *obj)
+{
+ return _PyObject_IS_GC(obj);
+}
+
static PyObject *
_PyObject_GC_Alloc(int use_calloc, size_t basicsize)
{
@@ -2317,7 +2323,7 @@
int
PyObject_GC_IsTracked(PyObject* obj)
{
- if (PyObject_IS_GC(obj) && _PyObject_GC_IS_TRACKED(obj)) {
+ if (_PyObject_IS_GC(obj) && _PyObject_GC_IS_TRACKED(obj)) {
return 1;
}
return 0;
@@ -2326,7 +2332,7 @@
int
PyObject_GC_IsFinalized(PyObject *obj)
{
- if (PyObject_IS_GC(obj) && _PyGCHead_FINALIZED(AS_GC(obj))) {
+ if (_PyObject_IS_GC(obj) && _PyGCHead_FINALIZED(AS_GC(obj))) {
return 1;
}
return 0;