bpo-39573: Porting to Python 3.10: Py_SET_SIZE() macro (GH-20610) · python/cpython@dc24b8a
@@ -135,17 +135,35 @@ Porting to Python 3.10
135135136136* Since :c:func:`Py_TYPE()` is changed to the inline static function,
137137 ``Py_TYPE(obj) = new_type`` must be replaced with ``Py_SET_TYPE(obj, new_type)``:
138- see :c:func:`Py_SET_TYPE()` (available since Python 3.9).
138+ see :c:func:`Py_SET_TYPE()` (available since Python 3.9). For backward
139+ compatibility, this macro can be used::
140+141+ #if PY_VERSION_HEX < 0x030900A4
142+ # define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0)
143+ #endif
144+139145 (Contributed by Dong-hee Na in :issue:`39573`.)
140146141147* Since :c:func:`Py_REFCNT()` is changed to the inline static function,
142148 ``Py_REFCNT(obj) = new_refcnt`` must be replaced with ``Py_SET_REFCNT(obj, new_refcnt)``:
143- see :c:func:`Py_SET_REFCNT()` (available since Python 3.9).
149+ see :c:func:`Py_SET_REFCNT()` (available since Python 3.9). For backward
150+ compatibility, this macro can be used::
151+152+ #if PY_VERSION_HEX < 0x030900A4
153+ # define Py_SET_REFCNT(obj, refcnt) ((Py_REFCNT(obj) = (refcnt)), (void)0)
154+ #endif
155+144156 (Contributed by Victor Stinner in :issue:`39573`.)
145157146158* Since :c:func:`Py_SIZE()` is changed to the inline static function,
147159 ``Py_SIZE(obj) = new_size`` must be replaced with ``Py_SET_SIZE(obj, new_size)``:
148- see :c:func:`Py_SET_SIZE()` (available since Python 3.9).
160+ see :c:func:`Py_SET_SIZE()` (available since Python 3.9). For backward
161+ compatibility, this macro can be used::
162+163+ #if PY_VERSION_HEX < 0x030900A4
164+ # define Py_SET_SIZE(obj, size) ((Py_SIZE(obj) = (size)), (void)0)
165+ #endif
166+149167 (Contributed by Victor Stinner in :issue:`39573`.)
150168151169* Calling :c:func:`PyDict_GetItem` without :term:`GIL` held had been allowed