gh-128509: Add PyUnstable_IsImmortal for finding immortal objects (GH-129182)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
This commit is contained in:
Peter Bierma 2025-01-27 08:36:33 -05:00 committed by GitHub
parent 7ec17429d4
commit 3fb5f6eb9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 51 additions and 5 deletions

View file

@ -3155,3 +3155,12 @@ Py_REFCNT(PyObject *ob)
{
return _Py_REFCNT(ob);
}
int
PyUnstable_IsImmortal(PyObject *op)
{
/* Checking a reference count requires a thread state */
_Py_AssertHoldsTstate();
assert(op != NULL);
return _Py_IsImmortal(op);
}