Skip to content

Commit

Permalink
[3.13] pythongh-117657: Make PyType_HasFeature (exported version) ato…
Browse files Browse the repository at this point in the history
…mic (pythonGH-120484) (python#120554)

pythongh-117657: Make PyType_HasFeature (exported version) atomic (pythonGH-120484)

Make PyType_HasFeature (exported version) atomic
(cherry picked from commit 6f63dff)

Co-authored-by: Ken Jin <[email protected]>
  • Loading branch information
miss-islington and Fidget-Spinner authored Jun 15, 2024
1 parent 13a5082 commit cbcb526
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,11 @@ PyType_HasFeature(PyTypeObject *type, unsigned long feature)
// PyTypeObject is opaque in the limited C API
flags = PyType_GetFlags(type);
#else
flags = type->tp_flags;
# ifdef Py_GIL_DISABLED
flags = _Py_atomic_load_ulong_relaxed(&type->tp_flags);
# else
flags = type->tp_flags;
# endif
#endif
return ((flags & feature) != 0);
}
Expand Down
2 changes: 1 addition & 1 deletion Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3435,7 +3435,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);
}


Expand Down

0 comments on commit cbcb526

Please sign in to comment.