]>
Commit | Line | Data |
---|---|---|
2efce5b5 JR |
1 | From 45d0154a1e0bf167656d1ef4050de782452aad2c Mon Sep 17 00:00:00 2001 |
2 | From: Victor Stinner <vstinner@redhat.com> | |
3 | Date: Wed, 31 Jul 2019 15:03:36 +0200 | |
4 | Subject: [PATCH] Fix Python method descriptors for Python 3.8 | |
5 | ||
6 | The Python binding cannot be loaded in Python 3.8: import libcomps | |
7 | fails with: | |
8 | ||
9 | Traceback (most recent call last): | |
10 | File "src/python/src/python3/libcomps/__init__.py", line 1, in <module> | |
11 | from ._libpycomps import * | |
12 | SystemError: bad call flags | |
13 | ||
14 | Fedora bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1734777 | |
15 | ||
16 | The problem are the following method descriptors of | |
17 | libcomps/src/python/src/pycomps.c: | |
18 | ||
19 | {"categories_match", (PyCFunction)PyCOMPS_categories_match, METH_KEYWORDS, | |
20 | PyCOMPS_validate__doc__}, | |
21 | {"environments_match", (PyCFunction)PyCOMPS_envs_match, METH_KEYWORDS, | |
22 | PyCOMPS_validate__doc__}, | |
23 | ||
24 | In Python 3.7, import didn't check descriptor flags (METH_KEYWORDS): | |
25 | these flags were only checked when the methods were called. | |
26 | ||
27 | In Python 3.8, the flags are checked at soon as the module is | |
28 | imported, which prevents the module to be imported. | |
29 | ||
30 | This change fix the two method descriptors. | |
31 | --- | |
32 | libcomps/src/python/src/pycomps.c | 4 ++-- | |
33 | 1 file changed, 2 insertions(+), 2 deletions(-) | |
34 | ||
35 | diff --git a/libcomps/src/python/src/pycomps.c b/libcomps/src/python/src/pycomps.c | |
36 | index b34685c..293a338 100644 | |
37 | --- a/libcomps/src/python/src/pycomps.c | |
38 | +++ b/libcomps/src/python/src/pycomps.c | |
39 | @@ -766,9 +766,9 @@ PyDoc_STRVAR(PyCOMPS_arch_filter__doc__, | |
40 | static PyMethodDef PyCOMPS_methods[] = { | |
41 | {"groups_match", (PyCFunction)PyCOMPS_groups_match, METH_VARARGS | METH_KEYWORDS, | |
42 | PyCOMPS_validate__doc__}, | |
43 | - {"categories_match", (PyCFunction)PyCOMPS_categories_match, METH_KEYWORDS, | |
44 | + {"categories_match", (PyCFunction)PyCOMPS_categories_match, METH_VARARGS | METH_KEYWORDS, | |
45 | PyCOMPS_validate__doc__}, | |
46 | - {"environments_match", (PyCFunction)PyCOMPS_envs_match, METH_KEYWORDS, | |
47 | + {"environments_match", (PyCFunction)PyCOMPS_envs_match, METH_VARARGS | METH_KEYWORDS, | |
48 | PyCOMPS_validate__doc__}, | |
49 | {"validate", (PyCFunction)PyCOMPS_validate, METH_NOARGS, | |
50 | PyCOMPS_validate__doc__}, |