Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1897148
Summary: | m2crypto fails to build with Python 3.10: PyObject_AsReadBuffer() is removed | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Tomáš Hrnčiar <thrnciar> | ||||||||||
Component: | m2crypto | Assignee: | Neal Gompa <ngompa13> | ||||||||||
Status: | CLOSED RAWHIDE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||||||||
Severity: | unspecified | Docs Contact: | |||||||||||
Priority: | unspecified | ||||||||||||
Version: | rawhide | CC: | gholms, mcepl, mhroncok, ngompa13, pviktori, python-sig, thrnciar | ||||||||||
Target Milestone: | --- | Keywords: | Reopened | ||||||||||
Target Release: | --- | ||||||||||||
Hardware: | Unspecified | ||||||||||||
OS: | Unspecified | ||||||||||||
Whiteboard: | |||||||||||||
Fixed In Version: | m2crypto-0.38.0-1.fc35 | Doc Type: | If docs needed, set a value | ||||||||||
Doc Text: | Story Points: | --- | |||||||||||
Clone Of: | Environment: | ||||||||||||
Last Closed: | 2021-06-25 03:21:47 UTC | Type: | Bug | ||||||||||
Regression: | --- | Mount Type: | --- | ||||||||||
Documentation: | --- | CRM: | |||||||||||
Verified Versions: | Category: | --- | |||||||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||||||
Embargoed: | |||||||||||||
Bug Depends On: | |||||||||||||
Bug Blocks: | 1890881, 1927309, 1927313, 1968820, 1968843, 1968854 | ||||||||||||
Attachments: |
|
Description
Tomáš Hrnčiar
2020-11-12 12:45:36 UTC
BTW 0.36.0 does not fix this, see https://src.fedoraproject.org/rpms/m2crypto/pull-request/4 and https://copr.fedorainfracloud.org/coprs/g/python/python3.10/builds/?dirname=python3.10:pr:4 This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle. Changing version to 34. Hello Neal, is there any update on this? There are two packages depending on m2crypto (ipsilon and module-build-service), we cannot test them with Python 3.10 without it. Thank you Sorry, I forgot to close this when I updated m2crypto 0.37.1. This should be fixed now: https://gitlab.com/m2crypto/m2crypto/-/commit/6bb65c27f01dd69f08c4654ce531fb283c7bcc07 This is a mass-posted update. Sorry if it is not 100% accurate to this bugzilla. The Python 3.10 rebuild is in progress in a Koji side tag. If you manage to fix the problem, please commit the fix in the rawhide branch, but don't build the package in regular rawhide. You can either build the package in the side tag, with: $ fedpkg build --target=f35-python Or you can the build and we will eventually build it for you. Note that the rebuild is still in progress, so not all (build) dependencies of this package might be available right away. Thanks. See also https://fedoraproject.org/wiki/Changes/Python3.10 If you have general questions about the rebuild, please use this mailing list thread: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/G47SGOYIQLRDTWGOSLSWERZSSHXDEDH5/ The f35-python side tag has been merged to Rawhide. From now on, build as you would normally build. *** Bug 1968836 has been marked as a duplicate of this bug. *** I don't know how to fix this, Miro. :( SWIG/_lib.i has: ... if (PyObject_CheckBuffer(obj)) { ... } else { ... PyObject_AsReadBuffer(obj, buffer, &len) ... } The else branch cannot use PyObject_AsReadBuffer. I don't really know what should be done if PyObject_CheckBuffer() is 0. What is the idea here? Created attachment 1789543 [details]
An incomplete patch
The attached patch makes it compile and import, but I guess some alternate else branches must be provided, otherwise there is some missing exception handling.
======================================================================
ERROR: test_private_encrypt (tests.test_rsa.RSATestCase)
----------------------------------------------------------------------
TypeError: a bytes-like object is required, not 'method'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/builddir/build/BUILD/M2Crypto-0.37.1/tests/test_rsa.py", line 114, in test_private_encrypt
priv.private_encrypt(self.gen_callback, RSA.pkcs1_padding)
File "/builddir/build/BUILD/M2Crypto-0.37.1/M2Crypto/RSA.py", line 77, in private_encrypt
return m2.rsa_private_encrypt(self.rsa, data, padding)
SystemError: <built-in function rsa_private_encrypt> returned a result with an exception set
======================================================================
ERROR: test_public_encrypt (tests.test_rsa.RSATestCase)
----------------------------------------------------------------------
TypeError: a bytes-like object is required, not 'method'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/builddir/build/BUILD/M2Crypto-0.37.1/tests/test_rsa.py", line 133, in test_public_encrypt
priv.public_encrypt(self.gen_callback, RSA.pkcs1_padding)
File "/builddir/build/BUILD/M2Crypto-0.37.1/M2Crypto/RSA.py", line 67, in public_encrypt
return m2.rsa_public_encrypt(self.rsa, data, padding)
SystemError: <built-in function rsa_public_encrypt> returned a result with an exception set
----------------------------------------------------------------------
Created attachment 1789544 [details]
An incomplete patch
An updated but still incomplete patch
Created attachment 1789545 [details]
An incomplete patch
Progress:
======================================================================
ERROR: test_private_encrypt (tests.test_rsa.RSATestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/builddir/build/BUILD/M2Crypto-0.37.1/tests/test_rsa.py", line 114, in test_private_encrypt
priv.private_encrypt(self.gen_callback, RSA.pkcs1_padding)
File "/builddir/build/BUILD/M2Crypto-0.37.1/M2Crypto/RSA.py", line 77, in private_encrypt
return m2.rsa_private_encrypt(self.rsa, data, padding)
ValueError: help me, I am trapped in this patch
======================================================================
ERROR: test_public_encrypt (tests.test_rsa.RSATestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/builddir/build/BUILD/M2Crypto-0.37.1/tests/test_rsa.py", line 133, in test_public_encrypt
priv.public_encrypt(self.gen_callback, RSA.pkcs1_padding)
File "/builddir/build/BUILD/M2Crypto-0.37.1/M2Crypto/RSA.py", line 67, in public_encrypt
return m2.rsa_public_encrypt(self.rsa, data, padding)
ValueError: help me, I am trapped in this patch
----------------------------------------------------------------------
Ran 370 tests in 70.509s
I still have no idea what should be done if PyObject_CheckBuffer fails :/
Created attachment 1789565 [details] Patch that owkrs with Python 3.10 Thanks to Petr Viktorin, I have a working patch: Attached and in https://src.fedoraproject.org/rpms/m2crypto/pull-request/6 The problem was in the exception type I was rising. Not sure if applicable upstream as is, I leave that you you. It is likely not Python 2 compatible and not even tested on Python 3.9 by me. > Patch that owkrs with Python 3.10
Should have been "works"
The changes to m2_PyObject_AsReadBuffer should be good for any Python. Raising TypeError rather than trying PyObject_AsReadBuffer is OK on Python 3: up to 3.9, the old buffer protocol is just a wrapper over the new one. But in Python 2, I think it is possible for an object to implement the old protocol but not the new one. So in those 2 places (m2_PyObject_AsReadBuffer*), upstream you might want to add #ifdef on the Python version. Recognized upstream https://gitlab.com/m2crypto/m2crypto/-/issues/297 M2Crypto 0.38.0 should be what you are looking for. I hope. |