Skip to content

Commit

Permalink
Python 3.11 support
Browse files Browse the repository at this point in the history
Py_TYPE() changed to a inline static function, replace it with
Py_SET_TYPE(). Include a backwards compatibility macro.

See: bpo-39573
  • Loading branch information
stefanor committed Nov 18, 2022
1 parent cf6676a commit f96c318
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/ipp/ippmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
#include <arpa/inet.h>
#include "pv.h"

#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 set_read_only(attrib) \
static int set_##attrib( \
IPprefixObject *self, PyObject *value, void *closure) { \
Expand Down Expand Up @@ -931,7 +937,7 @@ PyMODINIT_FUNC initipp(void) {

if (PyType_Ready(&IPprefixType) < 0)
RETURN;
Py_TYPE(&IPprefixType) = &PyType_Type;
Py_SET_TYPE(&IPprefixType, &PyType_Type);

#if PYTHON3
m = PyModule_Create(&ipp_module);
Expand Down

0 comments on commit f96c318

Please sign in to comment.