summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-04-14 18:11:20 (GMT)
committerGitHub <noreply@github.com>2020-04-14 18:11:20 (GMT)
commit675d9a3d7afc767a2818c84da7ba4bf4181dcf26 (patch)
tree621da3f9078df542c36e8bb856c6d86da4ce52b0 /Modules
parenta5900ecf9f22e65bef489633692e9ea6941379c5 (diff)
downloadcpython-675d9a3d7afc767a2818c84da7ba4bf4181dcf26.zip
cpython-675d9a3d7afc767a2818c84da7ba4bf4181dcf26.tar.gz
cpython-675d9a3d7afc767a2818c84da7ba4bf4181dcf26.tar.bz2
bpo-40170: Convert PyObject_IS_GC() macro to a function (GH-19464)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/gcmodule.c22
1 files changed, 14 insertions, 8 deletions
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 @@ visit_decref(PyObject *op, void *parent)
{
_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 @@ subtract_refs(PyGC_Head *containers)
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 @@ clear_unreachable_mask(PyGC_Head *unreachable)
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 @@ gc_get_referents(PyObject *self, PyObject *args)
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 @@ gc_is_tracked(PyObject *module, PyObject *obj)
{
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 @@ static PyObject *
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 @@ PyObject_GC_UnTrack(void *op_raw)
}
}
+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 @@ PyObject_GC_Del(void *op)
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 @@ PyObject_GC_IsTracked(PyObject* obj)
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;