From bec8dbc9de31b2939ad76e911fce1132467d921d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 31 Jul 2019 15:17:22 +0200 Subject: [PATCH] Fix Python method descriptors for Python 3.8 https://github.com/rpm-software-management/libcomps/pull/50 https://bugzilla.redhat.com/show_bug.cgi?id=1734777 --- 50.patch | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ libcomps.spec | 8 ++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 50.patch diff --git a/50.patch b/50.patch new file mode 100644 index 0000000..2b7b58d --- /dev/null +++ b/50.patch @@ -0,0 +1,50 @@ +From 45d0154a1e0bf167656d1ef4050de782452aad2c 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__}, diff --git a/libcomps.spec b/libcomps.spec index f19cd85..c9cb35e 100644 --- a/libcomps.spec +++ b/libcomps.spec @@ -14,12 +14,13 @@ Name: libcomps Version: 0.1.11 -Release: 2%{?dist} +Release: 3%{?dist} 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 +Patch1: %{url}/pull/50.patch BuildRequires: gcc-c++ BuildRequires: cmake @@ -91,7 +92,7 @@ Python3 bindings for libcomps library. %endif %prep -%autosetup -n %{name}-%{name}-%{version} +%autosetup -p1 -n %{name}-%{name}-%{version} %if %{with python2} mkdir build-py2 @@ -189,6 +190,9 @@ popd %endif %changelog +* Wed Jul 31 2019 Miro HronĨok - 0.1.11-3 +- Fix Python method descriptors for Python 3.8 (#1734777) + * Thu Jul 25 2019 Fedora Release Engineering - 0.1.11-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild