m2crypto fails to build with Python 3.10.0a2. ImportError: /builddir/build/BUILD/M2Crypto-0.35.2/M2Crypto/_m2crypto.cpython-310-x86_64-linux-gnu.so: undefined symbol: PyObject_AsReadBuffer bpo-41103: PyObject_AsCharBuffer(), PyObject_AsReadBuffer(), PyObject_CheckReadBuffer(), and PyObject_AsWriteBuffer() are removed. Please migrate to new buffer protocol; PyObject_GetBuffer() and PyBuffer_Release(). https://docs.python.org/3.10/whatsnew/changelog.html#id16 For the build logs, see: https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/01757146-m2crypto/ For all our attempts to build m2crypto with Python 3.10, see: https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/m2crypto/ Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.10: https://copr.fedorainfracloud.org/coprs/g/python/python3.10/ Let us know here if you have any questions. Python 3.10 will be included in Fedora 35. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.10. A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon. We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.
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
But it is not. See https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/m2crypto/
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.
Released into Rawhide: https://src.fedoraproject.org/rpms/m2crypto/c/e7d562393c5a1981cb5cad00e6ce55e6c4d1e2aa?branch=rawhide