https://github.com/python/cpython/commit/6f63dfff6f493b405f3422210a168369e1e7a35d
commit: 6f63dfff6f493b405f3422210a168369e1e7a35d
branch: main
author: Ken Jin <[email protected]>
committer: Fidget-Spinner <[email protected]>
date: 2024-06-15T22:39:22+08:00
summary:
gh-117657: Make PyType_HasFeature (exported version) atomic (#120484)
Make PyType_HasFeature (exported version) atomic
files:
M Include/object.h
M Objects/typeobject.c
diff --git a/Include/object.h b/Include/object.h
index 4a39ada8c7daa4..f71aaee7efe6ee 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -756,7 +756,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);
}
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 98e00bd25c3205..eb296414bb7bef 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -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);
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]