From c19c3a09618ac400538ee412f84be4c1196c7bab Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 30 Nov 2021 12:14:45 +0100 Subject: bpo-45476: Add _Py_RVALUE() macro (GH-29860) Add a new _Py_RVALUE() macro to prevent using an expression as an l-value. Replace a "(void)" cast with the _Py_RVALUE() macro in the following macros: * PyCell_SET() * PyList_SET_ITEM() * PyTuple_SET_ITEM() * _PyGCHead_SET_FINALIZED() * _PyGCHead_SET_NEXT() * asdl_seq_SET() * asdl_seq_SET_UNTYPED() Add also parentheses around macro arguments in PyCell_SET() and PyTuple_SET_ITEM() macros. --- Include/cpython/tupleobject.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Include/cpython/tupleobject.h') diff --git a/Include/cpython/tupleobject.h b/Include/cpython/tupleobject.h index 7cada8848c..fc37c4e6de 100644 --- a/Include/cpython/tupleobject.h +++ b/Include/cpython/tupleobject.h @@ -23,6 +23,6 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *); #define PyTuple_GET_ITEM(op, i) (_PyTuple_CAST(op)->ob_item[i]) /* Macro, *only* to be used to fill in brand new tuples */ -#define PyTuple_SET_ITEM(op, i, v) ((void)(_PyTuple_CAST(op)->ob_item[i] = v)) +#define PyTuple_SET_ITEM(op, i, v) _Py_RVALUE(_PyTuple_CAST(op)->ob_item[i] = (v)) PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out); -- cgit v1.2.1