mirror of https://github.com/python/cpython
gh-117657: Make PyType_HasFeature (exported version) atomic (#120484)
Make PyType_HasFeature (exported version) atomic
This commit is contained in:
parent
99d62f902e
commit
6f63dfff6f
|
@ -755,8 +755,12 @@ PyType_HasFeature(PyTypeObject *type, unsigned long feature)
|
|||
#ifdef Py_LIMITED_API
|
||||
// PyTypeObject is opaque in the limited C API
|
||||
flags = PyType_GetFlags(type);
|
||||
#else
|
||||
# ifdef Py_GIL_DISABLED
|
||||
flags = _Py_atomic_load_ulong_relaxed(&type->tp_flags);
|
||||
# else
|
||||
flags = type->tp_flags;
|
||||
# endif
|
||||
#endif
|
||||
return ((flags & feature) != 0);
|
||||
}
|
||||
|
|
|
@ -3599,7 +3599,7 @@ type_init(PyObject *cls, PyObject *args, PyObject *kwds)
|
|||
unsigned long
|
||||
PyType_GetFlags(PyTypeObject *type)
|
||||
{
|
||||
return type->tp_flags;
|
||||
return FT_ATOMIC_LOAD_ULONG_RELAXED(type->tp_flags);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue