mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-40170: Convert PyObject_IS_GC() macro to a function (GH-19464)
This commit is contained in:
parent
a5900ecf9f
commit
675d9a3d7a
7 changed files with 41 additions and 15 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue