Using python-snappy with Python 3.8 or 3.9 produces this deprecation warning:
DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
To fix this issue define PY_SSIZE_T_CLEAN before including python.h:
#define PY_SSIZE_T_CLEAN #include "Python.h"
You will also need to change the type passed to '#'
formats from int
to Py_ssize_t
, eg:
snappy__is_valid_compressed_buffer(PyObject *self, PyObject *args) { const char * compressed; - int comp_size; + Py_ssize_t comp_size; snappy_status status; #if PY_MAJOR_VERSION >=3 if (!PyArg_ParseTuple(args, "y#", &compressed, &comp_size)) #else if (!PyArg_ParseTuple(args, "s#", &compressed, &comp_size)) #endif ...
References:
- https://docs.python.org/3.8/c-api/arg.html#strings-and-buffers
- https://docs.python.org/3.8/whatsnew/changelog.html?highlight=py_ssize_t_clean#id147
- python/cpython@0895793
- The “Conversion guidelines” section in PEP 353 — Using ssize_t as the index type is also worth a read.