Skip to content

Commit a3ad3e5

Browse files
committed
Add Py_NewRef compatibility for Python < 3.10
1 parent 1a98fa7 commit a3ad3e5

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

c_src/py_nif.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@
136136
#endif
137137
#endif
138138

139+
/**
140+
* Py_NewRef was added in Python 3.10. Provide compatibility macro for older versions.
141+
*/
142+
#if PY_VERSION_HEX < 0x030A0000
143+
static inline PyObject *Py_NewRef(PyObject *o) {
144+
Py_INCREF(o);
145+
return o;
146+
}
147+
#endif
148+
139149
/** @} */
140150

141151
/* Include subinterpreter pool header for shared-GIL pool model */

0 commit comments

Comments
 (0)