Fix compatibility with Python 3.10

Signed-off-by: Igor Raits <ignatenkobrain@fedoraproject.org>
This commit is contained in:
Igor Raits 2021-07-18 19:10:26 +02:00
parent 6b483d9404
commit 9272baea89
No known key found for this signature in database
GPG Key ID: 115D5AB89C5C1E1E
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,37 @@
From cbf668383d83f29dd9e61ca224c242b2db337663 Mon Sep 17 00:00:00 2001
From: Igor Raits <igor.raits@gmail.com>
Date: Sun, 18 Jul 2021 18:47:05 +0200
Subject: [PATCH] Fix compatibility with Python 3.10
Fixes: https://github.com/openSUSE/libsolv/issues/461
Signed-off-by: Igor Raits <igor.raits@gmail.com>
---
bindings/solv.i | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/bindings/solv.i b/bindings/solv.i
index 3bbeca04..abfb5e15 100644
--- a/bindings/solv.i
+++ b/bindings/solv.i
@@ -10,6 +10,12 @@
%markfunc Pool "mark_Pool";
#endif
+#ifdef SWIGPYTHON
+%begin %{
+#define PY_SSIZE_T_CLEAN
+%}
+#endif
+
/**
** binaryblob handling
**/
@@ -69,7 +75,7 @@ typedef struct {
%typemap(out,noblock=1,fragment="SWIG_FromCharPtrAndSize") BinaryBlob {
#if defined(SWIGPYTHON) && defined(PYTHON3)
- $result = $1.data ? Py_BuildValue("y#", $1.data, $1.len) : SWIG_Py_Void();
+ $result = $1.data ? Py_BuildValue("y#", $1.data, (Py_ssize_t)$1.len) : SWIG_Py_Void();
#elif defined(SWIGTCL)
Tcl_SetObjResult(interp, $1.data ? Tcl_NewByteArrayObj($1.data, $1.len) : NULL);
#else

View File

@ -29,6 +29,7 @@ Summary: Package dependency solver
License: BSD License: BSD
URL: https://github.com/openSUSE/libsolv URL: https://github.com/openSUSE/libsolv
Source: %{url}/archive/%{version}/%{name}-%{version}.tar.gz Source: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
Patch0001: https://github.com/openSUSE/libsolv/pull/462.patch#/0001-Fix-compatibility-with-Python-3.10.patch
BuildRequires: cmake BuildRequires: cmake
BuildRequires: gcc-c++ BuildRequires: gcc-c++