bpo-39573: Porting to Python 3.10: Py_SET_SIZE() macro (GH-20610) · python/cpython@dc24b8a (original) (raw)

`@@ -135,17 +135,35 @@ Porting to Python 3.10

`

135

135

``

136

136

`` * Since :c:func:Py_TYPE() is changed to the inline static function,

``

137

137

``` 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`

`+`

`139`

`145`

``  (Contributed by Dong-hee Na in :issue:`39573`.)

``

`140`

`146`

``

`141`

`147`

`` * Since :c:func:`Py_REFCNT()` is changed to the inline static function,

``

`142`

`148`

```  ``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

+

144

156

`` (Contributed by Victor Stinner in :issue:39573.)

``

145

157

``

146

158

`` * Since :c:func:Py_SIZE() is changed to the inline static function,

``

147

159

``` 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

+

149

167

`` (Contributed by Victor Stinner in :issue:39573.)

``

150

168

``

151

169

`` * Calling :c:func:PyDict_GetItem without :term:GIL held had been allowed

``