Bug 1893649 - python-requests-toolbelt fails to build with Python 3.10
Summary: python-requests-toolbelt fails to build with Python 3.10
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: python-requests-toolbelt
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Parag Nemade
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.10
TreeView+ depends on / blocked
 
Reported: 2020-11-02 10:04 UTC by Tomáš Hrnčiar
Modified: 2020-11-02 10:31 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-02 10:31:43 UTC
Type: Bug


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2020-11-02 10:04:29 UTC
python-requests-toolbelt fails to build with Python 3.10.0a1.

=================================== FAILURES ===================================
________________________ TestX509Adapter.test_x509_der _________________________

self = <tests.test_x509_adapter.TestX509Adapter testMethod=test_x509_der>

    @pytest.mark.skipif(not REQUESTS_SUPPORTS_SSL_CONTEXT,
                    reason="Requires Requests v2.12.0 or later")
    def test_x509_der(self):
        p12 = load_pkcs12(self.pkcs12_data, self.pkcs12_password_bytes)
        cert_bytes = p12.get_certificate().to_cryptography().public_bytes(Encoding.DER)
        pk_bytes = p12.get_privatekey().to_cryptography_key().private_bytes(Encoding.DER, PrivateFormat.PKCS8, NoEncryption())
>       adapter = X509Adapter(max_retries=3, cert_bytes=cert_bytes, pk_bytes=pk_bytes, encoding=Encoding.DER)

tests/test_x509_adapter.py:55: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
requests_toolbelt/adapters/x509.py:106: in __init__
    self.ssl_context = create_ssl_context(cert_bytes, pk_bytes,
requests_toolbelt/adapters/x509.py:176: in create_ssl_context
    ssl_context._ctx.use_certificate(X509.from_cryptography(cert))
/usr/lib/python3.10/site-packages/OpenSSL/SSL.py:960: in use_certificate
    _raise_current_error()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

exception_type = <class 'OpenSSL.SSL.Error'>

    def exception_from_error_queue(exception_type):
        """
        Convert an OpenSSL library failure into a Python exception.
    
        When a call to the native OpenSSL library fails, this is usually signalled
        by the return value, and an error code is stored in an error queue
        associated with the current thread. The err library provides functions to
        obtain these error codes and textual error messages.
        """
        errors = []
    
        while True:
            error = lib.ERR_get_error()
            if error == 0:
                break
            errors.append((
                text(lib.ERR_lib_error_string(error)),
                text(lib.ERR_func_error_string(error)),
                text(lib.ERR_reason_error_string(error))))
    
>       raise exception_type(errors)
E       OpenSSL.SSL.Error: [('SSL routines', 'SSL_CTX_use_certificate', 'ee key too small')]

/usr/lib/python3.10/site-packages/OpenSSL/_util.py:54: Error
________________________ TestX509Adapter.test_x509_pem _________________________

self = <tests.test_x509_adapter.TestX509Adapter testMethod=test_x509_pem>

    @pytest.mark.skipif(not REQUESTS_SUPPORTS_SSL_CONTEXT,
                    reason="Requires Requests v2.12.0 or later")
    def test_x509_pem(self):
        p12 = load_pkcs12(self.pkcs12_data, self.pkcs12_password_bytes)
        cert_bytes = p12.get_certificate().to_cryptography().public_bytes(Encoding.PEM)
        pk_bytes = p12.get_privatekey().\
                       to_cryptography_key().\
                       private_bytes(Encoding.PEM, PrivateFormat.PKCS8,
                                     BestAvailableEncryption(self.pkcs12_password_bytes))
    
>       adapter = X509Adapter(max_retries=3, cert_bytes=cert_bytes,
                              pk_bytes=pk_bytes, password=self.pkcs12_password_bytes)

tests/test_x509_adapter.py:39: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
requests_toolbelt/adapters/x509.py:106: in __init__
    self.ssl_context = create_ssl_context(cert_bytes, pk_bytes,
requests_toolbelt/adapters/x509.py:176: in create_ssl_context
    ssl_context._ctx.use_certificate(X509.from_cryptography(cert))
/usr/lib/python3.10/site-packages/OpenSSL/SSL.py:960: in use_certificate
    _raise_current_error()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

exception_type = <class 'OpenSSL.SSL.Error'>

    def exception_from_error_queue(exception_type):
        """
        Convert an OpenSSL library failure into a Python exception.
    
        When a call to the native OpenSSL library fails, this is usually signalled
        by the return value, and an error code is stored in an error queue
        associated with the current thread. The err library provides functions to
        obtain these error codes and textual error messages.
        """
        errors = []
    
        while True:
            error = lib.ERR_get_error()
            if error == 0:
                break
            errors.append((
                text(lib.ERR_lib_error_string(error)),
                text(lib.ERR_func_error_string(error)),
                text(lib.ERR_reason_error_string(error))))
    
>       raise exception_type(errors)
E       OpenSSL.SSL.Error: [('SSL routines', 'SSL_CTX_use_certificate', 'ee key too small')]

/usr/lib/python3.10/site-packages/OpenSSL/_util.py:54: Error
=============================== warnings summary ===============================
tests/test_downloadutils.py::test_stream_response_to_specific_filename
  /builddir/build/BUILD/toolbelt-0.9.1/requests_toolbelt/downloadutils/stream.py:161: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
    if path and isinstance(getattr(path, 'write', None), collections.Callable):

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED tests/test_x509_adapter.py::TestX509Adapter::test_x509_der - OpenSSL.S...
FAILED tests/test_x509_adapter.py::TestX509Adapter::test_x509_pem - OpenSSL.S...
============= 2 failed, 159 passed, 8 skipped, 1 warning in 3.42s ==============
error: Bad exit status from /var/tmp/rpm-tmp.t89qWv (%check)
    Bad exit status from /var/tmp/rpm-tmp.t89qWv (%check)

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/01726341-python-requests-toolbelt/

For all our attempts to build python-requests-toolbelt with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/python-requests-toolbelt/

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.

Comment 1 Tomáš Hrnčiar 2020-11-02 10:31:43 UTC
Hello, 

I am sorry, I just noticed it was already fixed. Sorry for the noise. 

https://src.fedoraproject.org/rpms/python-requests-toolbelt/c/dbd0baf591363c920619f5d2721106adbc52da2d?branch=master


Note You need to log in before you can comment on or make changes to this bug.