Skip to content

Commit 556d97f

Browse files
authored
bpo-30459: Cast the result of PyList_SET_ITEM() to void (GH-19975)
Do the same for PyTuple_SET_ITEM().
1 parent 29afab6 commit 556d97f

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

Include/cpython/listobject.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
3030
#define _PyList_CAST(op) (assert(PyList_Check(op)), (PyListObject *)(op))
3131

3232
#define PyList_GET_ITEM(op, i) (_PyList_CAST(op)->ob_item[i])
33-
#define PyList_SET_ITEM(op, i, v) (_PyList_CAST(op)->ob_item[i] = (v))
33+
#define PyList_SET_ITEM(op, i, v) ((void)(_PyList_CAST(op)->ob_item[i] = (v)))
3434
#define PyList_GET_SIZE(op) Py_SIZE(_PyList_CAST(op))

Include/cpython/tupleobject.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
2323
#define PyTuple_GET_ITEM(op, i) (_PyTuple_CAST(op)->ob_item[i])
2424

2525
/* Macro, *only* to be used to fill in brand new tuples */
26-
#define PyTuple_SET_ITEM(op, i, v) (_PyTuple_CAST(op)->ob_item[i] = v)
26+
#define PyTuple_SET_ITEM(op, i, v) ((void)(_PyTuple_CAST(op)->ob_item[i] = v))
2727

2828
PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cast the result of :c:func:`PyList_SET_ITEM` and :c:func:`PyTuple_SET_ITEM`
2+
to void.

0 commit comments

Comments
 (0)