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

Closes: https://bugs.gentoo.org/736224
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
This commit is contained in:
Arthur Zamarin
2021-09-18 21:14:45 +03:00
parent 5ea4b6b615
commit 57ea44b8b8
2 changed files with 38 additions and 7 deletions

View File

@@ -0,0 +1,28 @@
From: Arthur Zamarin <arthurzam@gmail.com>
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 <arthurzam@gmail.com>
--- 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));
}
}

View File

@@ -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