Skip to content

Commit

Permalink
Added python3.11 compatibility for c-module
Browse files Browse the repository at this point in the history
  • Loading branch information
andershenja committed Jul 4, 2024
1 parent 7e47840 commit 62653c2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pyropo/pyropo_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ along with RAVE. If not, see <http://www.gnu.org/licenses/>.
PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \
ob = PyModule_Create(&moduledef);

#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE)
static inline void _Py_SET_TYPE(PyObject *ob, PyTypeObject *type)
{ ob->ob_type = type; }
#define Py_SET_TYPE(ob, type) _Py_SET_TYPE((PyObject*)(ob), type)
#endif

#define MOD_INIT_CREATE_CAPI(ptr, name) PyCapsule_New(ptr, name, NULL)
#define MOD_INIT_IS_CAPI(ptr) PyCapsule_CheckExact(ptr)
#define MOD_INIT_GET_CAPI(ptr, name) PyCapsule_GetPointer(ptr, name)
#define MOD_INIT_SETUP_TYPE(itype, otype) Py_TYPE(&itype) = otype
#define MOD_INIT_SETUP_TYPE(itype, otype) Py_SET_TYPE(&itype, otype)
#define MOD_INIT_VERIFY_TYPE_READY(type) if (PyType_Ready(type) < 0) return MOD_INIT_ERROR

#else
Expand Down

0 comments on commit 62653c2

Please sign in to comment.