From b6ec40ff1819a96fe077fa6d47f5f31af0f11b39 Mon Sep 17 00:00:00 2001 From: chenditang Date: Mon, 22 Jun 2020 19:38:02 +0800 Subject: [PATCH] Fix Python method descriptors for Python-3.8 --- ...on-method-descriptors-for-Python-3.8.patch | 53 +++++++++++++++++++ libcomps.spec | 11 +++- 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 Fix-Python-method-descriptors-for-Python-3.8.patch diff --git a/Fix-Python-method-descriptors-for-Python-3.8.patch b/Fix-Python-method-descriptors-for-Python-3.8.patch new file mode 100644 index 0000000..f974931 --- /dev/null +++ b/Fix-Python-method-descriptors-for-Python-3.8.patch @@ -0,0 +1,53 @@ +From dce9d5d3c1dce16efc223e5a55cec7122fb25276 Mon Sep 17 00:00:00 2001 +From: Victor Stinner +Date: Wed, 31 Jul 2019 15:03:36 +0200 +Subject: [PATCH] Fix Python method descriptors for Python 3.8 + +The Python binding cannot be loaded in Python 3.8: import libcomps +fails with: + + Traceback (most recent call last): + File "src/python/src/python3/libcomps/__init__.py", line 1, in + from ._libpycomps import * + SystemError: bad call flags + +Fedora bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1734777 + +The problem are the following method descriptors of +libcomps/src/python/src/pycomps.c: + + {"categories_match", (PyCFunction)PyCOMPS_categories_match, METH_KEYWORDS, + PyCOMPS_validate__doc__}, + {"environments_match", (PyCFunction)PyCOMPS_envs_match, METH_KEYWORDS, + PyCOMPS_validate__doc__}, + +In Python 3.7, import didn't check descriptor flags (METH_KEYWORDS): +these flags were only checked when the methods were called. + +In Python 3.8, the flags are checked at soon as the module is +imported, which prevents the module to be imported. + +This change fix the two method descriptors. +--- + libcomps/src/python/src/pycomps.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libcomps/src/python/src/pycomps.c b/libcomps/src/python/src/pycomps.c +index b34685c..293a338 100644 +--- a/libcomps/src/python/src/pycomps.c ++++ b/libcomps/src/python/src/pycomps.c +@@ -766,9 +766,9 @@ PyDoc_STRVAR(PyCOMPS_arch_filter__doc__, + static PyMethodDef PyCOMPS_methods[] = { + {"groups_match", (PyCFunction)PyCOMPS_groups_match, METH_VARARGS | METH_KEYWORDS, + PyCOMPS_validate__doc__}, +- {"categories_match", (PyCFunction)PyCOMPS_categories_match, METH_KEYWORDS, ++ {"categories_match", (PyCFunction)PyCOMPS_categories_match, METH_VARARGS | METH_KEYWORDS, + PyCOMPS_validate__doc__}, +- {"environments_match", (PyCFunction)PyCOMPS_envs_match, METH_KEYWORDS, ++ {"environments_match", (PyCFunction)PyCOMPS_envs_match, METH_VARARGS | METH_KEYWORDS, + PyCOMPS_validate__doc__}, + {"validate", (PyCFunction)PyCOMPS_validate, METH_NOARGS, + PyCOMPS_validate__doc__}, +-- +1.8.3.1 + diff --git a/libcomps.spec b/libcomps.spec index 8eda3fb..b06b672 100644 --- a/libcomps.spec +++ b/libcomps.spec @@ -3,13 +3,14 @@ Name: libcomps Version: 0.1.8 -Release: 20 +Release: 21 Summary: Comps XML file manipulation library License: GPLv2+ URL: https://github.com/rpm-software-management/libcomps Source0: %{url}/archive/%{name}-%{version}/%{name}-%{version}.tar.gz -Patch6000: CVE-2019-3817-Fix-UAF-in-comps_objmrtree_unite-function.patch +Patch0000: CVE-2019-3817-Fix-UAF-in-comps_objmrtree_unite-function.patch +Patch0001: Fix-Python-method-descriptors-for-Python-3.8.patch BuildRequires: gcc cmake zlib-devel libxml2-devel check-devel expat-devel @@ -136,6 +137,12 @@ popd %endif %changelog +* Mon Jun 22 2020 chenditang - 0.1.8-21 +- Type:enhancement +- ID:NA +- SUG:NA +- DESC:Fix Python method descriptors for Python-3.8. + * Thu Feb 20 2020 chengquan - 0.1.8-20 - Type:enhancement - ID:NA -- Gitee