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 1953538

Summary: python-asyncpg fails to build with Python 3.10: AssertionError: "invalid input for query argument \$1:.*an integer is required" does not match "invalid input for query argument $1: '2' ('str' object cannot be interpreted as an integer)"
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: python-asyncpgAssignee: Ben Beasley <code>
Status: CLOSED RAWHIDE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: code, mhroncok, thrnciar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 0.22.0-5 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-04-27 09:13:43 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    

Description Tomáš Hrnčiar 2021-04-26 10:43:45 UTC
python-asyncpg fails to build with Python 3.10.0a7.

=================================== FAILURES ===================================
________________________ TestCodecs.test_invalid_input _________________________

>   codec.encode(self.settings, writer, arg)

asyncpg/protocol/prepared_stmt.pyx:155: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   return self.encoder(self, settings, buf, obj)

asyncpg/protocol/codecs/base.pyx:193: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   self.c_encoder(settings, buf, obj)

asyncpg/protocol/codecs/base.pyx:104: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   val = cpython.PyLong_AsLong(obj)
E   TypeError: 'str' object cannot be interpreted as an integer

asyncpg/pgproto/codecs/int.pyx:30: TypeError

The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "asyncpg/protocol/prepared_stmt.pyx", line 155, in asyncpg.protocol.protocol.PreparedStatementState._encode_bind_msg
    codec.encode(self.settings, writer, arg)
  File "asyncpg/protocol/codecs/base.pyx", line 193, in asyncpg.protocol.protocol.Codec.encode
    return self.encoder(self, settings, buf, obj)
  File "asyncpg/protocol/codecs/base.pyx", line 104, in asyncpg.protocol.protocol.Codec.encode_scalar
    self.c_encoder(settings, buf, obj)
  File "asyncpg/pgproto/./codecs/int.pyx", line 30, in asyncpg.pgproto.pgproto.int2_encode
    val = cpython.PyLong_AsLong(obj)
TypeError: 'str' object cannot be interpreted as an integer

The above exception was the direct cause of the following exception:

asyncpg.exceptions.DataError: invalid input for query argument $1: '2' ('str' object cannot be interpreted as an integer)

During handling of the above exception, another exception occurred:

self = <tests.test_codecs.TestCodecs testMethod=test_invalid_input>

>   ???
E   AssertionError: "invalid input for query argument \$1:.*an integer is required" does not match "invalid input for query argument $1: '2' ('str' object cannot be interpreted as an integer)"

tests/test_codecs.py:-1: AssertionError
=========================== short test summary info ============================
FAILED tests/test_codecs.py::TestCodecs::test_invalid_input - AssertionError:...
=========== 1 failed, 271 passed, 2 skipped, 1 deselected in 55.35s ============

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

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

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 Ben Beasley 2021-04-26 12:33:29 UTC
Reported upstream (https://github.com/MagicStack/asyncpg/issues/750) and patched (see PR https://github.com/MagicStack/asyncpg/pull/751).

The latest koji build in Rawhide failed, as did the build in the Python 3.10 COPR—but right now every build with %{pypi_source} in the spec file is failing!

I will close this issue after the external problem is fixed and I can get a build done.

Comment 2 Miro Hrončok 2021-04-26 21:28:32 UTC
Interesting. Looking into the %{pypi_source} problme, might be related to RPM 4.17.

Comment 4 Miro Hrončok 2021-04-27 09:13:43 UTC
Built in Copr with fixed macros.

Comment 5 Ben Beasley 2021-04-27 12:57:52 UTC
Thanks for looking into this. I’ve now built the package in Rawhide too.

Comment 6 Ben Beasley 2021-04-27 12:59:56 UTC
Linking the bug for the %{pypi_source} problem for the benefit of any future Bugzilla archaeologists: https://bugzilla.redhat.com/show_bug.cgi?id=1953910