Skip to content

Commit 296c606

Browse files
committed
Fix old Python and PyPy
1 parent 76e6eac commit 296c606

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pythoncapi_compat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ PyDict_SetDefaultRef(PyObject *d, PyObject *key, PyObject *default_value,
13381338
}
13391339
#endif
13401340

1341-
#if PY_VERSION_HEX < 0x030E0000
1341+
#if PY_VERSION_HEX < 0x030E0000 && PY_VERSION_HEX >= 0x03060000 && !defined(PYPY_VERSION)
13421342
typedef struct PyUnicodeWriter PyUnicodeWriter;
13431343

13441344
static inline PyUnicodeWriter* PyUnicodeWriter_Create(void)

tests/test_pythoncapi_compat_cext.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,9 @@ test_get_constant(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
17241724
}
17251725

17261726

1727+
#if PY_VERSION_HEX < 0x030E0000 && PY_VERSION_HEX >= 0x03060000 && !defined(PYPY_VERSION)
1728+
#define TEST_UNICODEWRITER 1
1729+
17271730
static PyObject *
17281731
test_unicodewriter(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args))
17291732
{
@@ -1818,6 +1821,7 @@ test_unicodewriter_format(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args))
18181821
PyUnicodeWriter_Free(writer);
18191822
return NULL;
18201823
}
1824+
#endif
18211825

18221826

18231827
static struct PyMethodDef methods[] = {
@@ -1858,8 +1862,10 @@ static struct PyMethodDef methods[] = {
18581862
{"test_time", test_time, METH_NOARGS, _Py_NULL},
18591863
#endif
18601864
{"test_get_constant", test_get_constant, METH_NOARGS, _Py_NULL},
1865+
#ifdef TEST_UNICODEWRITER
18611866
{"test_unicodewriter", test_unicodewriter, METH_NOARGS, _Py_NULL},
18621867
{"test_unicodewriter_format", test_unicodewriter_format, METH_NOARGS, _Py_NULL},
1868+
#endif
18631869
{_Py_NULL, _Py_NULL, 0, _Py_NULL}
18641870
};
18651871

0 commit comments

Comments
 (0)