mirror of
https://github.com/boostorg/python.git
synced 2026-01-23 05:42:30 +00:00
Use strong reference APIs.
For the free-threaded build, it is not safe use borrowed references. Another thread could deallocate the object and cause the reference to become invalid. Replace API calls that borrow references with strong reference APIs.
This commit is contained in:
@@ -68,8 +68,16 @@ object dict_base::get(object_cref k) const
|
||||
{
|
||||
if (check_exact(this))
|
||||
{
|
||||
#ifdef Py_GIL_DISABLED
|
||||
PyObject* result;
|
||||
if (PyDict_GetItemRef(this->ptr(),k.ptr(),&result) < 0) {
|
||||
throw_error_already_set();
|
||||
}
|
||||
return object(detail::new_reference(result ? result : Py_None));
|
||||
#else
|
||||
PyObject* result = PyDict_GetItem(this->ptr(),k.ptr());
|
||||
return object(detail::borrowed_reference(result ? result : Py_None));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user