From 4e60054ecd13d0b09009657389fbfab5df7d19da Mon Sep 17 00:00:00 2001 From: Jamie Wilkinson Date: Sat, 2 Sep 2023 17:22:39 +1000 Subject: [PATCH] Set `PY_SSIZE_T_CLEAN` so that `y#` works with Python 3.11. Per https://docs.python.org/3/c-api/arg.html#strings-and-buffers we no longer fall back to `int` type for the buffer size. --- src/aomodule.c | 3 ++- src/aomodule.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/aomodule.c b/src/aomodule.c index ed083d8..4823372 100644 --- a/src/aomodule.c +++ b/src/aomodule.c @@ -364,11 +364,12 @@ py_ao_play(ao_Object *self, PyObject *args) const char *samples; char *output_samples; uint_32 num_bytes = 0; - int len; #if PY_MAJOR_VERSION >= 3 + Py_ssize_t len; if (!(PyArg_ParseTuple(args, "y#|O&", &samples, &len, uint_32_obj, &num_bytes))) #else + int len; if (!(PyArg_ParseTuple(args, "s#|O&", &samples, &len, uint_32_obj, &num_bytes))) #endif return NULL; diff --git a/src/aomodule.h b/src/aomodule.h index 17d3b84..b3c1fc1 100644 --- a/src/aomodule.h +++ b/src/aomodule.h @@ -19,6 +19,8 @@ #ifndef __AO_MODULE_H__ #define __AO_MODULE_H__ +#define PY_SSIZE_T_CLEAN + #include #include #include