]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Use PyBytes_AsStringAndSize() instead of PyObject_AsReadBuffer() for python3
authorMichael Schroeder <mls@suse.de>
Mon, 16 Nov 2020 12:45:13 +0000 (13:45 +0100)
committerMichael Schroeder <mls@suse.de>
Mon, 16 Nov 2020 12:45:13 +0000 (13:45 +0100)
PyObject_AsReadBuffer was deprecated since python-3.0 and has
now been removed in python-3.10.

Fixes issue #410

bindings/solv.i

index 48d3f1fb37790502fca249515070e13ee2955f1a..0a8389a25d025fbc3f0a77e01bca2e2a3898c20c 100644 (file)
@@ -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 {