Use Py_SET_SIZE() function by vstinner · Pull Request #330 · boostorg/python (original) (raw)
This looks like a duplicate of #328, doesn't it ?
Oh wait, ignore my previous comment. I wrote 2 PRs and I didn't notice that you're a talking about a 3rd PR.
Yes, #328 is the same fix, but it doesn't use pythoncapi_compat.h. I propose to use it to avoid having to reimplemented the compatibility layer for old Python versions:
#if PY_VERSION_HEX < 0x030900A4
# define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0)
# define Py_SET_SIZE(obj, size) ((Py_SIZE(obj) = (size)), (void)0)
#endif
pythoncapi_compat.h uses static inline functions rather than macros.