From 7f98763dd99d8545bafea4737514720efb8f47ec Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 18 May 2024 16:44:33 +0200 Subject: [PATCH] fix: constness issues related to PyArg_ParseTupleAndKeywords These have been fixed for Python 3.13+ For lower versions, just use a cast. --- src/pybase64/_pybase64.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pybase64/_pybase64.c b/src/pybase64/_pybase64.c index 76bebe3d..285762b0 100644 --- a/src/pybase64/_pybase64.c +++ b/src/pybase64/_pybase64.c @@ -1,5 +1,6 @@ #include "_pybase64_get_simd_flags.h" #define PY_SSIZE_T_CLEAN +#define PY_CXX_CONST const #include #include #include @@ -24,6 +25,11 @@ static int libbase64_simd_flag = 0; static uint32_t active_simd_flag = 0U; static uint32_t simd_flags; +#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x030d0000 +#define KW_CONST_CAST +#else +#define KW_CONST_CAST (char**) +#endif /* returns 0 on success */ static int get_buffer(PyObject* object, Py_buffer* buffer) @@ -325,7 +331,7 @@ static PyObject* pybase64_encode_impl(PyObject* self, PyObject* args, PyObject * char* dst; /* Parse the input tuple */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O", kwlist, &in_object, &in_alphabet)) { + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O", KW_CONST_CAST kwlist, &in_object, &in_alphabet)) { return NULL; } @@ -426,7 +432,7 @@ static PyObject* pybase64_decode_impl(PyObject* self, PyObject* args, PyObject * void* dest; /* Parse the input tuple */ - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Ob", kwlist, &in_object, &in_alphabet, &validation)) { + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Ob", KW_CONST_CAST kwlist, &in_object, &in_alphabet, &validation)) { return NULL; }