-
Notifications
You must be signed in to change notification settings - Fork 44
Fix Python method descriptors for Python 3.8 #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <module>
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.
Member
|
Thanks for the patch, merged! |
Contributor
|
This indeed never worked before (Python 3.7 example): >>> import libcomps
>>> c = libcomps.Comps()
>>> c.categories_match()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: Bad call flags in _PyMethodDef_RawFastCallKeywords. METH_OLDARGS is no longer supported!I wonder if this went unnoticed for so long - is this API even used anywhere? |
carlwgeorge
added a commit
to carlwgeorge/py-leveldb
that referenced
this pull request
Sep 8, 2019
Importing leveldb in Python 3.8 raises `SystemError: bad call flags`. This is due to a change in Python where the method descriptor flags are checked at import time, rather than when the methods are called. This change fixes the incorrect method description. Adapted from @vstinner's fix for the same problem in libcomps. rpm-software-management/libcomps#50
pbrezina
added a commit
to pbrezina/sssd
that referenced
this pull request
Sep 11, 2019
To fix this error that happened during mockbuild on rawhide. FAIL: src/tests/pysss-test.py3 ============================== ERROR: test_import (__main__.PysssImport) Import the module and assert it comes from tree ---------------------------------------------------------------------- Traceback (most recent call last): File "/builddir/build/BUILD/sssd-1.16.5/src/tests/pysss-test.py", line 56, in test_import import pysss SystemError: bad call flags 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 as soon as the module is imported, which prevents the module to be imported. Inspired by: rpm-software-management/libcomps#50 Python doc: https://docs.python.org/3/c-api/structures.html#METH_VARARGS
pbrezina
added a commit
to pbrezina/sssd
that referenced
this pull request
Sep 17, 2019
To fix this error that happened during mockbuild on rawhide. FAIL: src/tests/pysss-test.py3 ============================== ERROR: test_import (__main__.PysssImport) Import the module and assert it comes from tree ---------------------------------------------------------------------- Traceback (most recent call last): File "/builddir/build/BUILD/sssd-1.16.5/src/tests/pysss-test.py", line 56, in test_import import pysss SystemError: bad call flags 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 as soon as the module is imported, which prevents the module to be imported. Inspired by: rpm-software-management/libcomps#50 Python doc: https://docs.python.org/3/c-api/structures.html#METH_VARARGS
pbrezina
added a commit
to pbrezina/sssd
that referenced
this pull request
Sep 23, 2019
To fix this error that happened during mockbuild on rawhide. FAIL: src/tests/pysss-test.py3 ============================== ERROR: test_import (__main__.PysssImport) Import the module and assert it comes from tree ---------------------------------------------------------------------- Traceback (most recent call last): File "/builddir/build/BUILD/sssd-1.16.5/src/tests/pysss-test.py", line 56, in test_import import pysss SystemError: bad call flags 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 as soon as the module is imported, which prevents the module to be imported. Inspired by: rpm-software-management/libcomps#50 Python doc: https://docs.python.org/3/c-api/structures.html#METH_VARARGS
jhrozek
pushed a commit
to SSSD/sssd
that referenced
this pull request
Sep 23, 2019
To fix this error that happened during mockbuild on rawhide. FAIL: src/tests/pysss-test.py3 ============================== ERROR: test_import (__main__.PysssImport) Import the module and assert it comes from tree ---------------------------------------------------------------------- Traceback (most recent call last): File "/builddir/build/BUILD/sssd-1.16.5/src/tests/pysss-test.py", line 56, in test_import import pysss SystemError: bad call flags 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 as soon as the module is imported, which prevents the module to be imported. Inspired by: rpm-software-management/libcomps#50 Python doc: https://docs.python.org/3/c-api/structures.html#METH_VARARGS Reviewed-by: Tomáš Halman <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Python binding cannot be loaded in Python 3.8: import libcomps
fails with:
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:
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.