8000 Fix old Python and PyPy · python/pythoncapi-compat@b053c89 · GitHub
[go: up one dir, main page]

Skip to content

Commit b053c89

Browse files
committed
Fix old Python and PyPy
1 parent 4a87b43 commit b053c89

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
@@ -1727,6 +1727,9 @@ test_get_constant(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
17271727
}
17281728

17291729

1730+
#if PY_VERSION_HEX < 0x030E0000 && PY_VERSION_HEX >= 0x03060000 && !defined(PYPY_VERSION)
1731+
#define TEST_UNICODEWRITER 1
1732+
17301733
static PyObject *
17311734
test_unicodewriter(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args))
17321735
{
@@ -1821,6 +1824,7 @@ test_unicodewriter_format(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args))
18211824
PyUnicodeWriter_Free(writer);
18221825
return NULL;
18231826
}
1827+
#endif
18241828

18251829

18261830
static struct PyMethodDef methods[] = {
@@ -1861,8 +1865,10 @@ static struct PyMethodDef methods[] = {
18611865
{"test_time", test_time, METH_NOARGS, _Py_NULL},
18621866
#endif
18631867
{"test_get_constant", test_get_constant, METH_NOARGS, _Py_NULL},
1868+
#ifdef TEST_UNICODEWRITER
18641869
{"test_unicodewriter", test_unicodewriter, METH_NOARGS, _Py_NULL},
18651870
{"test_unicodewriter_format", test_unicodewriter_format, METH_NOARGS, _Py_NULL},
1871+
#endif
18661872
{_Py_NULL, _Py_NULL, 0, _Py_NULL}
18671873
};
18681874

0 commit comments

Comments
 (0)
0