]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-135906: Use `_PyObject_CAST` in internal headers (GH-135892)
authorCharlie Lin <tuug@gmx.us>
Mon, 7 Jul 2025 16:56:14 +0000 (16:56 +0000)
committerGitHub <noreply@github.com>
Mon, 7 Jul 2025 16:56:14 +0000 (12:56 -0400)
Fixes build errors encountered in python-greenlet/greenlet#450 when building greenlet on the free-threaded build.

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Include/internal/pycore_object.h
Include/internal/pycore_stackref.h
Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst [new file with mode: 0644]

index 8fe9875fae0687ca818cebcc313ae55271b3c7b1..40f8ca68c00b72c91db5e51f518afc74227c9594 100644 (file)
@@ -614,7 +614,7 @@ static inline PyObject *
 _Py_XGetRef(PyObject **ptr)
 {
     for (;;) {
-        PyObject *value = _Py_atomic_load_ptr(ptr);
+        PyObject *value = _PyObject_CAST(_Py_atomic_load_ptr(ptr));
         if (value == NULL) {
             return value;
         }
@@ -629,7 +629,7 @@ _Py_XGetRef(PyObject **ptr)
 static inline PyObject *
 _Py_TryXGetRef(PyObject **ptr)
 {
-    PyObject *value = _Py_atomic_load_ptr(ptr);
+    PyObject *value = _PyObject_CAST(_Py_atomic_load_ptr(ptr));
     if (value == NULL) {
         return value;
     }
index 48a40a4c3479c7c4d5f06af4e340a13a62ade762..6bf82d8322f50809552134d314ed1136c0941e47 100644 (file)
@@ -829,7 +829,7 @@ _Py_TryIncrefCompareStackRef(PyObject **src, PyObject *op, _PyStackRef *out)
 static inline int
 _Py_TryXGetStackRef(PyObject **src, _PyStackRef *out)
 {
-    PyObject *op = _Py_atomic_load_ptr_relaxed(src);
+    PyObject *op = _PyObject_CAST(_Py_atomic_load_ptr_relaxed(src));
     if (op == NULL) {
         *out = PyStackRef_NULL;
         return 1;
diff --git a/Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst b/Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst
new file mode 100644 (file)
index 0000000..7852759
--- /dev/null
@@ -0,0 +1 @@
+Fix compilation errors when compiling the internal headers with a C++ compiler.