Message403950
The Python C API provides "AS" functions to convert an object to another type, like PyFloat_AS_DOUBLE(). These macros can be abused to be used as l-value: "PyFloat_AS_DOUBLE(obj) = new_value;". It prevents to change the PyFloat implementation and makes life harder for Python implementations other than CPython.
I propose to convert these macros to static inline functions to disallow using them as l-value.
I made a similar change for Py_REFCNT(), Py_TYPE() and Py_SIZE(). For these functions, I added "SET" variants: Py_SET_REFCNT(), Py_SET_TYPE(), Py_SET_SIZE(). Here, I don't think that the l-value case is legit, and so I don't see the need to add a way to *set* a value.
For example, I don't think that PyFloat_SET_DOUBLE(obj, value) would make sense. A Python float object is supposed to be immutable. |
|
Date |
User |
Action |
Args |
2021-10-14 21:17:31 | vstinner | set | recipients:
+ vstinner |
2021-10-14 21:17:31 | vstinner | set | messageid: <1634246251.33.0.982878943146.issue45476@roundup.psfhosted.org> |
2021-10-14 21:17:31 | vstinner | link | issue45476 messages |
2021-10-14 21:17:31 | vstinner | create | |
|