mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-20 14:59:27 +00:00
Use new 3.14 C APIs when available (#5854)
* Use new 3.14 C APIs when available Use the new "unstable" C APIs for the functions added in #5494. * style: pre-commit fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -314,8 +314,9 @@ inline void traverse_offset_bases(void *valueptr,
|
|||||||
|
|
||||||
#ifdef Py_GIL_DISABLED
|
#ifdef Py_GIL_DISABLED
|
||||||
inline void enable_try_inc_ref(PyObject *obj) {
|
inline void enable_try_inc_ref(PyObject *obj) {
|
||||||
// TODO: Replace with PyUnstable_Object_EnableTryIncRef when available.
|
# if PY_VERSION_HEX >= 0x030E00A4
|
||||||
// See https://github.com/python/cpython/issues/128844
|
PyUnstable_EnableTryIncRef(obj);
|
||||||
|
# else
|
||||||
if (_Py_IsImmortal(obj)) {
|
if (_Py_IsImmortal(obj)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -330,6 +331,7 @@ inline void enable_try_inc_ref(PyObject *obj) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -253,9 +253,9 @@ PYBIND11_NOINLINE handle get_type_handle(const std::type_info &tp, bool throw_if
|
|||||||
|
|
||||||
inline bool try_incref(PyObject *obj) {
|
inline bool try_incref(PyObject *obj) {
|
||||||
// Tries to increment the reference count of an object if it's not zero.
|
// Tries to increment the reference count of an object if it's not zero.
|
||||||
// TODO: Use PyUnstable_TryIncref when available.
|
#if defined(Py_GIL_DISABLED) && PY_VERSION_HEX >= 0x030E00A4
|
||||||
// See https://github.com/python/cpython/issues/128844
|
return PyUnstable_TryIncRef(obj);
|
||||||
#ifdef Py_GIL_DISABLED
|
#elif defined(Py_GIL_DISABLED)
|
||||||
// See
|
// See
|
||||||
// https://github.com/python/cpython/blob/d05140f9f77d7dfc753dd1e5ac3a5962aaa03eff/Include/internal/pycore_object.h#L761
|
// https://github.com/python/cpython/blob/d05140f9f77d7dfc753dd1e5ac3a5962aaa03eff/Include/internal/pycore_object.h#L761
|
||||||
uint32_t local = _Py_atomic_load_uint32_relaxed(&obj->ob_ref_local);
|
uint32_t local = _Py_atomic_load_uint32_relaxed(&obj->ob_ref_local);
|
||||||
|
|||||||
Reference in New Issue
Block a user