aio-libs / aiopg

aiopg is a library for accessing a PostgreSQL database from the asyncio
http://aiopg.readthedocs.io
BSD 2-Clause "Simplified" License
1.39k stars 159 forks source link

AttributeError: 'Connection' object has no attribute 'send' #895

Closed llistochek closed 10 months ago

llistochek commented 1 year ago

Describe the bug

When using _ContextManager.send AttributeError is raised.

To Reproduce

import aiopg
import asyncio

async def test():
    con = aiopg.connect()
    con.send(None)

asyncio.run(test())

Expected behavior

It shouldn't crash

Logs/tracebacks

Traceback (most recent call last):
  File "/tmp/t.py", line 9, in <module>
    asyncio.run(test())
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/tmp/t.py", line 7, in test
    con.send(None)
  File "/home/llist/.local/lib/python3.9/site-packages/aiopg/utils.py", line 61, in send
    return self._coro.send(value)
AttributeError: 'Connection' object has no attribute 'send'

Python Version

Python 3.9.2

aiopg Version

Name: aiopg
Version: 1.4.0
Summary: Postgres integration with asyncio.
Home-page: https://aiopg.readthedocs.io
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: BSD
Location: /home/llist/.local/lib/python3.9/site-packages
Requires: psycopg2-binary, async-timeout
Required-by:

OS

Linux home 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21) x86_64 GNU/Linux

Additional context

No response

Code of Conduct

kshivakumar commented 10 months ago

Isn't send method applicable only to generators? Why is it present in a context manager object?