]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-135906: Use `_PyObject_CAST` in internal headers (GH-135892) (GH-136392)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 7 Jul 2025 17:21:28 +0000 (19:21 +0200)
committerGitHub <noreply@github.com>
Mon, 7 Jul 2025 17:21:28 +0000 (17:21 +0000)
gh-135906: Use `_PyObject_CAST` in internal headers (GH-135892)

Fixes build errors encountered in python-greenlet/greenlet#450 when building greenlet on the free-threaded build.

---------
(cherry picked from commit fe187fae8d8321f1b8d3c9560a35efe904de4217)

Co-authored-by: Charlie Lin <tuug@gmx.us>
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 1f9c7b1bf55b3f30e6f93ffcfb6c694bc0b8d099..12c5614834f56582d73c8990958c383934b93de1 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 21306b95f9c2e4d9a08ff8b1a541cacbb72ab922..0ce759fc743d823b5175c06eb6ff030f54ae22cb 100644 (file)
@@ -765,7 +765,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.