mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-128844: Make _Py_TryIncref
public as an unstable API. (#128926)
This exposes `_Py_TryIncref` as `PyUnstable_TryIncref()` and the helper function `_PyObject_SetMaybeWeakref` as `PyUnstable_EnableTryIncRef`. These are helpers for dealing with unowned references in a safe way, particularly in the free threading build. Co-authored-by: Petr Viktorin <encukou@gmail.com>
This commit is contained in:
parent
7dd0a7e52e
commit
d23f5701ad
6 changed files with 160 additions and 0 deletions
|
@ -2588,6 +2588,20 @@ PyUnstable_Object_EnableDeferredRefcount(PyObject *op)
|
|||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
PyUnstable_TryIncRef(PyObject *op)
|
||||
{
|
||||
return _Py_TryIncref(op);
|
||||
}
|
||||
|
||||
void
|
||||
PyUnstable_EnableTryIncRef(PyObject *op)
|
||||
{
|
||||
#ifdef Py_GIL_DISABLED
|
||||
_PyObject_SetMaybeWeakref(op);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_Py_ResurrectReference(PyObject *op)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue