bpo-30459: Cast the result of PyList_SET_ITEM() to void by ZackerySpytz · Pull Request #19975 · python/cpython (original) (raw)
By the way, I added Py_SET_REFCNT(), Py_SET_TYPE() and Py_SET_SIZE() in Python 3.9, but I left the related Py_REFCNT(), Py_TYPE() and Py_SIZE() unchanged. It remains possible to use them as l-value for example: Py_REFCNT(ob) = 1;
.
I expect that few C extensions use Py_REFCNT(ob) = 1;
, but maybe a few use Py_TYPE(op) = type;
. For Py_SIZE(ob) = size;
, Python 3.8 didn't provide any "abstract" setter function/macro, direct access to the member is also possible: ((PyVarObject*)ob)->ob_size = size;
,
I chose to add new macros in Python 3.9, and maybe change the macros in Python 3.10. The change is part of a larger project:
https://github.com/vstinner/misc/blob/master/cpython/pep-opaque-c-api.rst
See bpo-39573.