@@ -25,14 +25,18 @@ extern "C" {
2525#endif
2626
2727
28- // bpo-42262 added Py_NewRef() and Py_XNewRef() to Python 3.10.0a3
28+ // bpo-42262 added Py_NewRef() to Python 3.10.0a3
2929#if PY_VERSION_HEX < 0x030a00A3
3030static inline PyObject * Py_NewRef (PyObject * obj )
3131{
3232 Py_INCREF (obj );
3333 return obj ;
3434}
35+ #endif
36+
3537
38+ // bpo-42262 added Py_XNewRef() to Python 3.10.0a3
39+ #if PY_VERSION_HEX < 0x030a00A3
3640static inline PyObject * Py_XNewRef (PyObject * obj )
3741{
3842 Py_XINCREF (obj );
@@ -41,33 +45,39 @@ static inline PyObject* Py_XNewRef(PyObject *obj)
4145#endif
4246
4347
44- // bpo-39573: Py_TYPE(), Py_REFCNT() and Py_SIZE() can no longer be used
45- // as l-value in Python 3.10.
46- #if PY_VERSION_HEX < 0x030900A4
48+ // bpo-39573 added Py_SET_REFCNT() to Python 3.9.0a4
49+ #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_REFCNT )
4750static inline void _Py_SET_REFCNT (PyObject * ob , Py_ssize_t refcnt )
4851{
4952 ob -> ob_refcnt = refcnt ;
5053}
5154#define Py_SET_REFCNT (ob , refcnt ) _Py_SET_REFCNT((PyObject*)(ob), refcnt)
55+ #endif
5256
5357
58+ // bpo-39573 added Py_SET_TYPE() to Python 3.9.0a4
59+ #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE )
5460static inline void
5561_Py_SET_TYPE (PyObject * ob , PyTypeObject * type )
5662{
5763 ob -> ob_type = type ;
5864}
5965#define Py_SET_TYPE (ob , type ) _Py_SET_TYPE((PyObject*)(ob), type)
66+ #endif
67+
6068
69+ // bpo-39573 added Py_SET_SIZE() to Python 3.9.0a4
70+ #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_SIZE )
6171static inline void
6272_Py_SET_SIZE (PyVarObject * ob , Py_ssize_t size )
6373{
6474 ob -> ob_size = size ;
6575}
6676#define Py_SET_SIZE (ob , size ) _Py_SET_SIZE((PyVarObject*)(ob), size)
67-
68- #endif // PY_VERSION_HEX < 0x030900A4
77+ #endif
6978
7079
80+ // bpo-40421 added PyFrame_GetCode() to Python 3.9.0b1
7181#if PY_VERSION_HEX < 0x030900B1
7282static inline PyCodeObject *
7383PyFrame_GetCode (PyFrameObject * frame )
@@ -89,6 +99,7 @@ _PyFrame_GetCodeBorrow(PyFrameObject *frame)
8999}
90100
91101
102+ // bpo-40421 added PyFrame_GetCode() to Python 3.9.0b1
92103#if PY_VERSION_HEX < 0x030900B1
93104static inline PyFrameObject *
94105PyFrame_GetBack (PyFrameObject * frame )
@@ -109,6 +120,7 @@ _PyFrame_GetBackBorrow(PyFrameObject *frame)
109120}
110121
111122
123+ // bpo-39947 added PyThreadState_GetInterpreter() to Python 3.9.0a5
112124#if PY_VERSION_HEX < 0x030900A5
113125static inline PyInterpreterState *
114126PyThreadState_GetInterpreter (PyThreadState * tstate )
@@ -119,6 +131,7 @@ PyThreadState_GetInterpreter(PyThreadState *tstate)
119131#endif
120132
121133
134+ // bpo-40429 added PyThreadState_GetFrame() to Python 3.9.0b1
122135#if PY_VERSION_HEX < 0x030900B1
123136static inline PyFrameObject *
124137PyThreadState_GetFrame (PyThreadState * tstate )
@@ -139,6 +152,7 @@ _PyThreadState_GetFrameBorrow(PyThreadState *tstate)
139152}
140153
141154
155+ // bpo-39947 added PyInterpreterState_Get() to Python 3.9.0a5
142156#if PY_VERSION_HEX < 0x030900A5
143157static inline PyInterpreterState *
144158PyInterpreterState_Get (void )
@@ -156,6 +170,7 @@ PyInterpreterState_Get(void)
156170#endif
157171
158172
173+ // bpo-39947 added PyInterpreterState_Get() to Python 3.9.0a6
159174#if 0x030700A1 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x030900A6
160175static inline uint64_t
161176PyThreadState_GetID (PyThreadState * tstate )
@@ -166,6 +181,7 @@ PyThreadState_GetID(PyThreadState *tstate)
166181#endif
167182
168183
184+ // bpo-37194 added PyObject_CallNoArgs() to Python 3.9.0a1
169185#if PY_VERSION_HEX < 0x030900A1
170186static inline PyObject *
171187PyObject_CallNoArgs (PyObject * func )
@@ -175,6 +191,8 @@ PyObject_CallNoArgs(PyObject *func)
175191#endif
176192
177193
194+ // bpo-39245 made PyObject_CallOneArg() public (previously called
195+ // _PyObject_CallOneArg) in Python 3.9.0a4
178196#if PY_VERSION_HEX < 0x030900A4
179197static inline PyObject *
180198PyObject_CallOneArg (PyObject * func , PyObject * arg )
@@ -184,6 +202,7 @@ PyObject_CallOneArg(PyObject *func, PyObject *arg)
184202#endif
185203
186204
205+ // bpo-40024 added PyModule_AddType() to Python 3.9.0a5
187206#if PY_VERSION_HEX < 0x030900A5
188207static inline int
189208PyModule_AddType (PyObject * module , PyTypeObject * type )
@@ -211,6 +230,8 @@ PyModule_AddType(PyObject *module, PyTypeObject *type)
211230#endif
212231
213232
233+ // bpo-40241 added PyObject_GC_IsTracked() and PyObject_GC_IsFinalized()
234+ // to Python 3.9.0a6
214235#if PY_VERSION_HEX < 0x030900A6
215236static inline int
216237PyObject_GC_IsTracked (PyObject * obj )
@@ -226,7 +247,8 @@ PyObject_GC_IsFinalized(PyObject *obj)
226247#endif // PY_VERSION_HEX < 0x030900A6
227248
228249
229- #if PY_VERSION_HEX < 0x030900A4
250+ // bpo-39573 added Py_IS_TYPE() to Python 3.9.0a4
251+ #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_IS_TYPE )
230252static inline int
231253_Py_IS_TYPE (const PyObject * ob , const PyTypeObject * type ) {
232254 return ob -> ob_type == type ;
0 commit comments