Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions include/pybind11/detail/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,9 @@ inline void traverse_offset_bases(void *valueptr,

#ifdef Py_GIL_DISABLED
inline void enable_try_inc_ref(PyObject *obj) {
// TODO: Replace with PyUnstable_Object_EnableTryIncRef when available.
// See https://github.com/python/cpython/issues/128844
# if PY_VERSION_HEX >= 0x030E00A4
PyUnstable_EnableTryIncRef(obj);
# else
if (_Py_IsImmortal(obj)) {
return;
}
Expand All @@ -330,6 +331,7 @@ inline void enable_try_inc_ref(PyObject *obj) {
return;
}
}
# endif
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions include/pybind11/detail/type_caster_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ PYBIND11_NOINLINE handle get_type_handle(const std::type_info &tp, bool throw_if

inline bool try_incref(PyObject *obj) {
// Tries to increment the reference count of an object if it's not zero.
// TODO: Use PyUnstable_TryIncref when available.
// See https://github.com/python/cpython/issues/128844
#ifdef Py_GIL_DISABLED
#if defined(Py_GIL_DISABLED) && PY_VERSION_HEX >= 0x030E00A4
return PyUnstable_TryIncRef(obj);
#elif defined(Py_GIL_DISABLED)
// See
// 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);
Expand Down