Skip to content

Commit a8ac6c2

Browse files
committed
Make tests again compatible with Python 3.8
1 parent 7e4b037 commit a8ac6c2

File tree

1 file changed

+12
-0
lines changed
  • graalpython/com.oracle.graal.python.test/src/tests/cpyext

1 file changed

+12
-0
lines changed

graalpython/com.oracle.graal.python.test/src/tests/cpyext/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ def file_not_empty(path):
149149
#include <Python.h>
150150
{defines}
151151
152+
#if !GRAALVM_PYTHON && (PY_VERSION_HEX < 0x03090000)
153+
#define Py_SET_REFCNT(ob, v) ((_PyObject_CAST(ob)->ob_refcnt = (v)))
154+
#define Py_SET_TYPE(ob, v) ((_PyObject_CAST(ob)->ob_type) = (v))
155+
#define Py_SET_SIZE(ob, v) ((_PyVarObject_CAST(ob)->ob_size = (Py_ssize_t) (v)))
156+
#endif
157+
152158
{customcode}
153159
154160
static PyObject* test_{capifunction}(PyObject* module, PyObject* args) {{
@@ -466,6 +472,12 @@ def CPyExtType(name, code, **kwargs):
466472
template = """
467473
#include "Python.h"
468474
475+
#if !GRAALVM_PYTHON && (PY_VERSION_HEX < 0x03090000)
476+
#define Py_SET_REFCNT(ob, v) ((_PyObject_CAST(ob)->ob_refcnt = (v)))
477+
#define Py_SET_TYPE(ob, v) ((_PyObject_CAST(ob)->ob_type) = (v))
478+
#define Py_SET_SIZE(ob, v) ((_PyVarObject_CAST(ob)->ob_size = (Py_ssize_t) (v)))
479+
#endif
480+
469481
{includes}
470482
471483
typedef struct {{

0 commit comments

Comments
 (0)