mirror of https://github.com/python/cpython
bpo-30459: Cast the result of PyCell_SET to void (GH-23654)
This commit is contained in:
parent
c266736ec1
commit
0ef96c2b2a
|
@ -611,6 +611,13 @@ Porting to Python 3.10
|
||||||
:ref:`Python Path Configuration. <init-path-config>`.
|
:ref:`Python Path Configuration. <init-path-config>`.
|
||||||
(Contributed by Victor Stinner in :issue:`42260`.)
|
(Contributed by Victor Stinner in :issue:`42260`.)
|
||||||
|
|
||||||
|
* :c:func:`PyList_SET_ITEM`, :c:func:`PyTuple_SET_ITEM` and
|
||||||
|
:c:func:`PyCell_SET` macros can no longer be used as l-value or r-value.
|
||||||
|
For example, ``x = PyList_SET_ITEM(a, b, c)`` and
|
||||||
|
``PyList_SET_ITEM(a, b, c) = x`` now fail with a compiler error. It prevents
|
||||||
|
bugs like ``if (PyList_SET_ITEM (a, b, c) < 0) ...`` test.
|
||||||
|
(Contributed by Zackery Spytz and Victor Stinner in :issue:`30459`.)
|
||||||
|
|
||||||
Deprecated
|
Deprecated
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);
|
||||||
PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *);
|
PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *);
|
||||||
|
|
||||||
#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref)
|
#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref)
|
||||||
#define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v)
|
#define PyCell_SET(op, v) ((void)(((PyCellObject *)(op))->ob_ref = v))
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
Cast the result of :c:func:`PyList_SET_ITEM` and :c:func:`PyTuple_SET_ITEM`
|
:c:func:`PyList_SET_ITEM`, :c:func:`PyTuple_SET_ITEM` and :c:func:`PyCell_SET`
|
||||||
to void.
|
macros can no longer be used as l-value or r-value. For example,
|
||||||
|
``x = PyList_SET_ITEM(a, b, c)`` and ``PyList_SET_ITEM(a, b, c) = x`` now fail
|
||||||
|
with a compiler error. It prevents bugs like
|
||||||
|
``if (PyList_SET_ITEM (a, b, c) < 0) ...`` test.
|
||||||
|
Patch by Zackery Spytz and Victor Stinner.
|
||||||
|
|
Loading…
Reference in New Issue