MagicStack / MagicStack/asyncpg
"AttributeError: 'NoneType' object has no attribute 'decode'" when executing empty script
オープン
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 8.1k
- フォーク
- 468
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
asyncpg/connection.py の Connection.execute から始め、asyncpg/protocol/protocol.pyx に示されているプロトコルのクエリパス、特に _on_result__simple_query を追ってください。コメントだけのクエリを再現し、その後、NoneType のデコードエラーなしで正常に完了し、空でないクエリに対する通常の結果を維持できるように、カバレッジを追加または更新してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- postgresql, python
- 領域
- databases
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100