mirror of
https://github.com/python/cpython.git
synced 2025-09-10 10:47:34 +00:00
[3.13] gh-117657: Make PyType_HasFeature (exported version) atomic (GH-120484) (#120554)
gh-117657: Make PyType_HasFeature (exported version) atomic (GH-120484)
Make PyType_HasFeature (exported version) atomic
(cherry picked from commit 6f63dfff6f
)
Co-authored-by: Ken Jin <kenjin@python.org>
This commit is contained in:
parent
13a5082afe
commit
cbcb5265bf
2 changed files with 6 additions and 2 deletions
|
@ -1238,7 +1238,11 @@ PyType_HasFeature(PyTypeObject *type, unsigned long feature)
|
||||||
// PyTypeObject is opaque in the limited C API
|
// PyTypeObject is opaque in the limited C API
|
||||||
flags = PyType_GetFlags(type);
|
flags = PyType_GetFlags(type);
|
||||||
#else
|
#else
|
||||||
|
# ifdef Py_GIL_DISABLED
|
||||||
|
flags = _Py_atomic_load_ulong_relaxed(&type->tp_flags);
|
||||||
|
# else
|
||||||
flags = type->tp_flags;
|
flags = type->tp_flags;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
return ((flags & feature) != 0);
|
return ((flags & feature) != 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3435,7 +3435,7 @@ type_init(PyObject *cls, PyObject *args, PyObject *kwds)
|
||||||
unsigned long
|
unsigned long
|
||||||
PyType_GetFlags(PyTypeObject *type)
|
PyType_GetFlags(PyTypeObject *type)
|
||||||
{
|
{
|
||||||
return type->tp_flags;
|
return FT_ATOMIC_LOAD_ULONG_RELAXED(type->tp_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue