commit:     57ea44b8b8fdc2c57c3f8e0e328d12d2cecb3add
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 18 18:14:45 2021 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Sep 18 18:14:45 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=57ea44b8

dev-python/sabyenc: fix segfault, enable py3.10

Closes: https://bugs.gentoo.org/736224
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 .../sabyenc/files/sabyenc-4.0.2-fix-segfault.patch | 28 ++++++++++++++++++++++
 dev-python/sabyenc/sabyenc-4.0.2.ebuild            | 17 +++++++------
 2 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/dev-python/sabyenc/files/sabyenc-4.0.2-fix-segfault.patch 
b/dev-python/sabyenc/files/sabyenc-4.0.2-fix-segfault.patch
new file mode 100644
index 00000000000..1a80d5f13da
--- /dev/null
+++ b/dev-python/sabyenc/files/sabyenc-4.0.2-fix-segfault.patch
@@ -0,0 +1,28 @@
+From: Arthur Zamarin <[email protected]>
+Date: Sat, 18 Sep 2021 21:07:45 +0300
+Subject: Fix Segfault during testing
+
+decode_usenet_chunks might receive it argument as bytesarray, or
+as bytes object, but the C code expects only bytesarray.
+Add code, to apply variant for each case, and fail using assert when
+both don't apply.
+
+Signed-off-by: Arthur Zamarin <[email protected]>
+
+--- a/src/sabyenc3.c
++++ b/src/sabyenc3.c
+@@ -593,7 +593,13 @@ PyObject* decode_usenet_chunks(PyObject* self, PyObject* 
args) {
+         num_bytes_reserved = 0;
+         lp_max = (int)PyList_Size(Py_input_list);
+         for(lp = 0; lp < lp_max; lp++) {
+-            num_bytes_reserved += 
(int)PyByteArray_GET_SIZE(PyList_GetItem(Py_input_list, lp));
++            PyObject *temp = PyList_GetItem(Py_input_list, lp);
++            if (PyByteArray_Check(temp))
++                num_bytes_reserved += (int)PyByteArray_GET_SIZE(temp);
++            else if (PyBytes_Check(temp))
++                num_bytes_reserved += (int)PyBytes_GET_SIZE(temp);
++            else
++                assert(PyByteArray_Check(temp) || PyBytes_Check(temp));
+         }
+     }
+

diff --git a/dev-python/sabyenc/sabyenc-4.0.2.ebuild 
b/dev-python/sabyenc/sabyenc-4.0.2.ebuild
index f777975da68..d9536017b50 100644
--- a/dev-python/sabyenc/sabyenc-4.0.2.ebuild
+++ b/dev-python/sabyenc/sabyenc-4.0.2.ebuild
@@ -1,8 +1,9 @@
 # Copyright 1999-2021 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI="7"
-PYTHON_COMPAT=( python3_{7,8,9} )
+EAPI=7
+
+PYTHON_COMPAT=( python3_{8..10} )
 
 inherit distutils-r1
 
@@ -13,13 +14,15 @@ 
SRC_URI="https://github.com/sabnzbd/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
 LICENSE="LGPL-3"
 SLOT="0"
 KEYWORDS="amd64 ~x86"
-IUSE="test"
-RESTRICT="!test? ( test )"
-
-DOCS=( CHANGES.md README.md doc/yenc-draft.1.3.txt )
 
-DEPEND="test? (
+BDEPEND="test? (
                dev-python/chardet[${PYTHON_USEDEP}]
        )"
 
+DOCS=( CHANGES.md README.md doc/yenc-draft.1.3.txt )
+
+PATCHES=(
+       "${FILESDIR}/${P}-fix-segfault.patch"
+)
+
 distutils_enable_tests pytest

Reply via email to