From: Michael Schroeder Date: Mon, 16 Nov 2020 12:45:13 +0000 (+0100) Subject: Use PyBytes_AsStringAndSize() instead of PyObject_AsReadBuffer() for python3 X-Git-Tag: 0.7.17~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=170f8550b89c6c9e61b40e782cd75148825c2e89;p=thirdparty%2Flibsolv.git Use PyBytes_AsStringAndSize() instead of PyObject_AsReadBuffer() for python3 PyObject_AsReadBuffer was deprecated since python-3.0 and has now been removed in python-3.10. Fixes issue #410 --- diff --git a/bindings/solv.i b/bindings/solv.i index 48d3f1fb..0a8389a2 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -44,7 +44,11 @@ typedef struct { #if defined(SWIGPYTHON) const void *pybuf = 0; Py_ssize_t pysize = 0; +#if PY_VERSION_HEX >= 0x03000000 + res = PyBytes_AsStringAndSize($input, &pybuf, &pysize); +#else res = PyObject_AsReadBuffer($input, &pybuf, &pysize); +#endif if (res < 0) { %argument_fail(res, "BinaryBlob", $symname, $argnum); } else {