Skip to content

test_invalid_input fails with Python 3.10.0a7. #750

Closed
@musicinmybrain

Description

@musicinmybrain
  • asyncpg version: 0.22.0 or commit 6cfdb3a (latest as of this report)
  • PostgreSQL version: 12.6, not running.
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : N/A
  • Python version: 3.10.0a7
  • Platform: Fedora Linux 33 (x86_64) or 35
  • Do you use pgbouncer?: No
  • Did you install asyncpg with pip?: Built from source with pip install -e . as directed in docs/installation.rs; or, built from source without using pip as part of the Fedora Linux RPM build process.
  • If you built asyncpg locally, which version of Cython did you use?: 0.29.23; or, 0.29.22
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : I think this question does not make sense in this case.

On Python 3.10.0a7, test_invalid_input fails because the TypeError has message ('str' object cannot be interpreted as an integer), but the test code expects .*an integer is required.

======================================================================
FAIL: test_invalid_input (test_codecs.TestCodecs) (sample='2', typname='int2')
----------------------------------------------------------------------
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)
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:

Traceback (most recent call last):
  File "/home/ben/src/asyncpg/tests/test_codecs.py", line -1, in test_invalid_input
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)"

======================================================================
FAIL: test_invalid_input (test_codecs.TestCodecs) (sample='aa', typname='int2')
----------------------------------------------------------------------
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)
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: 'aa' ('str' object cannot be interpreted as an integer)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ben/src/asyncpg/tests/test_codecs.py", line -1, in test_invalid_input
AssertionError: "invalid input for query argument \$1:.*an integer is required" does not match "invalid input for query argument $1: 'aa' ('str' object cannot be interpreted as an integer)"

======================================================================
FAIL: test_invalid_input (test_codecs.TestCodecs) (sample='2', typname='int4')
----------------------------------------------------------------------
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)
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:

Traceback (most recent call last):
  File "/home/ben/src/asyncpg/tests/test_codecs.py", line -1, in test_invalid_input
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)"

======================================================================
FAIL: test_invalid_input (test_codecs.TestCodecs) (sample='aa', typname='int4')
----------------------------------------------------------------------
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)
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: 'aa' ('str' object cannot be interpreted as an integer)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ben/src/asyncpg/tests/test_codecs.py", line -1, in test_invalid_input
AssertionError: "invalid input for query argument \$1:.*an integer is required" does not match "invalid input for query argument $1: 'aa' ('str' object cannot be interpreted as an integer)"

======================================================================
FAIL: test_invalid_input (test_codecs.TestCodecs) (sample='2', typname='int8')
----------------------------------------------------------------------
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)
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:

Traceback (most recent call last):
  File "/home/ben/src/asyncpg/tests/test_codecs.py", line -1, in test_invalid_input
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)"

======================================================================
FAIL: test_invalid_input (test_codecs.TestCodecs) (sample='aa', typname='int8')
----------------------------------------------------------------------
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)
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: 'aa' ('str' object cannot be interpreted as an integer)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ben/src/asyncpg/tests/test_codecs.py", line -1, in test_invalid_input
AssertionError: "invalid input for query argument \$1:.*an integer is required" does not match "invalid input for query argument $1: 'aa' ('str' object cannot be interpreted as an integer)"

----------------------------------------------------------------------

See also downstream Fedora Linux bug 1953538 for more details. I am the maintainer of the python-asyncpg package in Fedora.

I am preparing a PR that would fix this by adjusting the test to accept either message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions