Skip to content

[3.14] gh-161185: Fix strict aliasing issue in Py_SETREF() macros family (GH-161186) (GH-161360) - #161362

Merged
vstinner merged 1 commit into
python:3.14from
miss-islington:backport-0dc1a96-3.14
Nov 4, 2026
Merged

vstinner merged 1 commit into
python:3.14from
miss-islington:backport-0dc1a96-3.14

Conversation

@miss-islington

Copy link
Copy Markdown
Contributor

gh-161185: Fix strict aliasing issue in Py_SETREF() macros family (GH-161186)

Py_SETREF(), Py_XSETREF() and Py_CLEAR() now use memcpy() to set
_tmp_old_dst/_tmp_old_op to fix a strict aliasing issue.

Py_SETREF(), Py_XSETREF() and Py_CLEAR() now also cast
_tmp_old_dst/_tmp_old_op to PyObject* when calling
Py_DECREF()/Py_XDECREF() to avoid compiler warnings with the limited
C API.

Add the _Py_TESTCEXT_NO_TYPEOF macro to undefine the _Py_TYPEOF
macro.

(cherry picked from commit f8e65ee)
(cherry picked from commit 0dc1a96)

Co-authored-by: Victor Stinner vstinner@python.org
Co-authored-by: Nathan Goldbaum nathan.goldbaum@gmail.com

…os family (pythonGH-161186) (pythonGH-161360)

pythongh-161185: Fix strict aliasing issue in Py_SETREF() macros family (pythonGH-161186)

Py_SETREF(), Py_XSETREF() and Py_CLEAR() now use memcpy() to set
_tmp_old_dst/_tmp_old_op to fix a strict aliasing issue.

Py_SETREF(), Py_XSETREF() and Py_CLEAR() now also cast
_tmp_old_dst/_tmp_old_op to PyObject* when calling
Py_DECREF()/Py_XDECREF() to avoid compiler warnings with the limited
C API.

Add the _Py_TESTCEXT_NO_TYPEOF macro to undefine the _Py_TYPEOF
macro.

(cherry picked from commit f8e65ee)
(cherry picked from commit 0dc1a96)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants