"AttributeError: 'NoneType' object has no attribute 'decode'" when executing empty script
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu với asyncpg/connection.py tại Connection.execute và lần theo đường dẫn truy vấn của giao thức được thể hiện trong asyncpg/protocol/protocol.pyx, đặc biệt là _on_result__simple_query. Tái hiện truy vấn chỉ chứa chú thích, sau đó thêm hoặc cập nhật độ bao phủ để truy vấn hoàn tất thành công mà không gặp lỗi giải mã NoneType và vẫn giữ nguyên các kết quả bình thường đối với những truy vấn không rỗng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Wouldn't it be natural that executing a script with only comments is a no-op returning OK?
Such that for example commenting out the contents of a migration script while developing runs the script as a no-op.
Instead what happens when running this:
import os
import asyncpg
import asyncio
async def main():
conn = await asyncpg.connect(os.environ["DATABASE_URI"])
async with conn.transaction():
await conn.execute("-- hello")
if __name__ == "__main__":
asyncio.run(main())
Is this:
Traceback (most recent call last):
File "/home/msa/dev/sandbox/pgtesting/hello.py", line 13, in <module>
asyncio.run(main())
~~~~~~~~~~~^^^^^^^^
File "/home/msa/.local/share/uv/python/cpython-3.13.0-linux-x86_64-gnu/lib/python3.13/asyncio/runners.py", line 194, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "/home/msa/.local/share/uv/python/cpython-3.13.0-linux-x86_64-gnu/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/home/msa/.local/share/uv/python/cpython-3.13.0-linux-x86_64-gnu/lib/python3.13/asyncio/base_events.py", line 721, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/home/msa/dev/sandbox/pgtesting/hello.py", line 9, in main
await conn.execute("-- hello")
File "/home/msa/dev/sandbox/pgtesting/.venv/lib/python3.13/site-packages/asyncpg/connection.py", line 349, in execute
result = await self._protocol.query(query, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "asyncpg/protocol/protocol.pyx", line 375, in query
File "asyncpg/protocol/protocol.pyx", line 888, in asyncpg.protocol.protocol.BaseProtocol._dispatch_result
File "asyncpg/protocol/protocol.pyx", line 815, in asyncpg.protocol.protocol.BaseProtocol._on_result__simple_query
AttributeError: 'NoneType' object has no attribute 'decode'
Setup is just
mkdir hello
cd hello
uv init .
uv add asyncpg
export DATABUTTON_URI="something"
uv run hello.py # above example
- Ngôn ngữ chính
- Python
- Star
- 8.1k
- Fork
- 469
- Merge trung bình
- 4 giờ 42 phút
- Pull request đã merge (30 ngày)
- 6
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MagicStack/asyncpg
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MagicStack/asyncpg#1357 ·
-
tests fail in 2032 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
MagicStack/asyncpg#997 ·
-
Connection.close(timeout=) waits forever on a pending cancel when the server never acknowledges it Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
MagicStack/asyncpg#1356 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
MagicStack/asyncpg#1354 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
MagicStack/asyncpg#1342 ·
Tất cả issue của MagicStack/asyncpg
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
use-agent-os/agent-os#3314 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
BasedHardware/omi#15662 · 1 bình luận ·
-
documentation help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
AiursoftWeb/AnduinOS-2#19 ·