diff options
author | Sam Gross <colesbury@gmail.com> | 2024-02-28 20:37:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-28 20:37:59 (GMT) |
commit | df5212df6c6f08308c68de4b3ed8a1b51ac6334b (patch) | |
tree | 997513f818daa2f5798b88c1f4b07e8492003c61 /Modules/gcmodule.c | |
parent | c43b26d02eaa103756c250e8d36829d388c5f3be (diff) | |
download | cpython-df5212df6c6f08308c68de4b3ed8a1b51ac6334b.zip cpython-df5212df6c6f08308c68de4b3ed8a1b51ac6334b.tar.gz cpython-df5212df6c6f08308c68de4b3ed8a1b51ac6334b.tar.bz2 |
gh-112529: Simplify PyObject_GC_IsTracked and PyObject_GC_IsFinalized (#114732)
Diffstat (limited to 'Modules/gcmodule.c')
-rw-r--r-- | Modules/gcmodule.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 961165e..9807d2e 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -383,7 +383,7 @@ error: /*[clinic input] -gc.is_tracked +gc.is_tracked -> bool obj: object / @@ -393,21 +393,15 @@ Returns true if the object is tracked by the garbage collector. Simple atomic objects will return false. [clinic start generated code]*/ -static PyObject * -gc_is_tracked(PyObject *module, PyObject *obj) -/*[clinic end generated code: output=14f0103423b28e31 input=d83057f170ea2723]*/ +static int +gc_is_tracked_impl(PyObject *module, PyObject *obj) +/*[clinic end generated code: output=91c8d086b7f47a33 input=423b98ec680c3126]*/ { - PyObject *result; - - if (_PyObject_IS_GC(obj) && _PyObject_GC_IS_TRACKED(obj)) - result = Py_True; - else - result = Py_False; - return Py_NewRef(result); + return PyObject_GC_IsTracked(obj); } /*[clinic input] -gc.is_finalized +gc.is_finalized -> bool obj: object / @@ -415,14 +409,11 @@ gc.is_finalized Returns true if the object has been already finalized by the GC. [clinic start generated code]*/ -static PyObject * -gc_is_finalized(PyObject *module, PyObject *obj) -/*[clinic end generated code: output=e1516ac119a918ed input=201d0c58f69ae390]*/ +static int +gc_is_finalized_impl(PyObject *module, PyObject *obj) +/*[clinic end generated code: output=401ff5d6fc660429 input=ca4d111c8f8c4e3a]*/ { - if (_PyObject_IS_GC(obj) && _PyGC_FINALIZED(obj)) { - Py_RETURN_TRUE; - } - Py_RETURN_FALSE; + return PyObject_GC_IsFinalized(obj); } /*[clinic input] |