mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[3.14] gh-133980: use atomic store in PyObject_GenericSetDict
(GH-133988) (#134354)
gh-133980: use atomic store in `PyObject_GenericSetDict` (GH-133988)
(cherry picked from commit ec39fd2c20
)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
parent
b0bf48a134
commit
87d7a19ef0
2 changed files with 23 additions and 1 deletions
|
@ -1931,7 +1931,13 @@ PyObject_GenericSetDict(PyObject *obj, PyObject *value, void *context)
|
|||
return -1;
|
||||
}
|
||||
Py_BEGIN_CRITICAL_SECTION(obj);
|
||||
Py_XSETREF(*dictptr, Py_NewRef(value));
|
||||
PyObject *olddict = *dictptr;
|
||||
FT_ATOMIC_STORE_PTR_RELEASE(*dictptr, Py_NewRef(value));
|
||||
#ifdef Py_GIL_DISABLED
|
||||
_PyObject_XDecRefDelayed(olddict);
|
||||
#else
|
||||
Py_XDECREF(olddict);
|
||||
#endif
|
||||
Py_END_CRITICAL_SECTION();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue