From b471043b6cd43878ac5b3cf16110af6f1ae7d887 Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Tue, 24 Jun 2025 13:24:15 +0000 Subject: [PATCH 1/7] Use _Py_STATIC_CAST in _Py_TryXGetStackRef --- Include/internal/pycore_stackref.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/internal/pycore_stackref.h b/Include/internal/pycore_stackref.h index 10e7199269eb40..224db9f253e099 100644 --- a/Include/internal/pycore_stackref.h +++ b/Include/internal/pycore_stackref.h @@ -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 = _Py_STATIC_CAST(PyObject*, _Py_atomic_load_ptr_relaxed(src)); if (op == NULL) { *out = PyStackRef_NULL; return 1; From e205e0ad5c9e06798f6e8c5293cead1478212eac Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Tue, 24 Jun 2025 13:29:00 +0000 Subject: [PATCH 2/7] Use _Py_STATIC_CAST in Include/internal/pycore_object.h --- Include/internal/pycore_object.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h index 50807e68e9a70c..e007f795ed5ce7 100644 --- a/Include/internal/pycore_object.h +++ b/Include/internal/pycore_object.h @@ -614,7 +614,7 @@ static inline PyObject * _Py_XGetRef(PyObject **ptr) { for (;;) { - PyObject *value = _Py_atomic_load_ptr(ptr); + PyObject *value = _Py_STATIC_CAST(PyObject*, _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 = _Py_STATIC_CAST(PyObject*, _Py_atomic_load_ptr(ptr)); if (value == NULL) { return value; } From de9016cfff97b6d40659661434cc80f86894f04f Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 25 Jun 2025 01:03:11 +0000 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst 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 index 00000000000000..002d209121a49e --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst @@ -0,0 +1 @@ +Fix compilation errors when compiling with a C++ compiler and internal CPython headers are (indirectly) included From b54a5db8b2d95e99c4ef7ce85b6a135a1dba0304 Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Wed, 25 Jun 2025 01:06:36 +0000 Subject: [PATCH 4/7] Use _PyObject_CAST in Include/internal/pycore_object.h --- Include/internal/pycore_object.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h index e007f795ed5ce7..c35ef9c0adb82f 100644 --- a/Include/internal/pycore_object.h +++ b/Include/internal/pycore_object.h @@ -614,7 +614,7 @@ static inline PyObject * _Py_XGetRef(PyObject **ptr) { for (;;) { - PyObject *value = _Py_STATIC_CAST(PyObject*, _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_STATIC_CAST(PyObject*, _Py_atomic_load_ptr(ptr)); + PyObject *value = _PyObject_CAST(_Py_atomic_load_ptr(ptr)); if (value == NULL) { return value; } From 7bbfa8c0537659e0dd75435b08eaac7fcc03432c Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Wed, 25 Jun 2025 01:07:49 +0000 Subject: [PATCH 5/7] Use _PyObject_CAST for one function --- Include/internal/pycore_stackref.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/internal/pycore_stackref.h b/Include/internal/pycore_stackref.h index 224db9f253e099..6da6d054a89f5a 100644 --- a/Include/internal/pycore_stackref.h +++ b/Include/internal/pycore_stackref.h @@ -829,7 +829,7 @@ _Py_TryIncrefCompareStackRef(PyObject **src, PyObject *op, _PyStackRef *out) static inline int _Py_TryXGetStackRef(PyObject **src, _PyStackRef *out) { - PyObject *op = _Py_STATIC_CAST(PyObject*, _Py_atomic_load_ptr_relaxed(src)); + PyObject *op = _PyObject_CAST( _Py_atomic_load_ptr_relaxed(src)); if (op == NULL) { *out = PyStackRef_NULL; return 1; From 62eb149699869fac1553d5e89b6abb3474cc4ea5 Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Thu, 26 Jun 2025 23:33:13 +0000 Subject: [PATCH 6/7] Update Misc/NEWS.d/next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst Co-authored-by: Peter Bierma --- .../next/C_API/2025-06-25-01-03-10.gh-issue-135906.UBrCWq.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 002d209121a49e..7852759a702804 100644 --- 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 @@ -1 +1 @@ -Fix compilation errors when compiling with a C++ compiler and internal CPython headers are (indirectly) included +Fix compilation errors when compiling the internal headers with a C++ compiler. From 2e909b3da9bfaa311bafd17a537439ac16744632 Mon Sep 17 00:00:00 2001 From: Charlie Lin Date: Thu, 3 Jul 2025 13:07:50 +0000 Subject: [PATCH 7/7] Update Include/internal/pycore_stackref.h Co-authored-by: Victor Stinner --- Include/internal/pycore_stackref.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/internal/pycore_stackref.h b/Include/internal/pycore_stackref.h index 6da6d054a89f5a..a901f228202b60 100644 --- a/Include/internal/pycore_stackref.h +++ b/Include/internal/pycore_stackref.h @@ -829,7 +829,7 @@ _Py_TryIncrefCompareStackRef(PyObject **src, PyObject *op, _PyStackRef *out) static inline int _Py_TryXGetStackRef(PyObject **src, _PyStackRef *out) { - PyObject *op = _PyObject_CAST( _Py_atomic_load_ptr_relaxed(src)); + PyObject *op = _PyObject_CAST(_Py_atomic_load_ptr_relaxed(src)); if (op == NULL) { *out = PyStackRef_NULL; return 1;