asyncio: SSL transport raises AttributeError after close() in connection_lost()
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- python
- 領域
- networking
調査の方向性
Start by locating _SSLProtocolTransport.close() and the asyncio SSL transport tests; the issue identifies that method as the source and includes a reproduction. Check the behavior of write(), set_protocol(), get_write_buffer_size(), get_extra_info() and the sendfile() fallback after close; done means these paths no longer raise the reported AttributeError and the fallback reports the expected connection error.
索引モデルが issue の本文から書いたものです。
説明
Bug report
If a protocol closes its SSL transport in connection_lost(), which is a common pattern, later calls on the transport fail:
import asyncio
from test.test_asyncio import utils as tu
class Proto(asyncio.Protocol):
def connection_made(self, tr):
self.tr = tr
def connection_lost(self, exc):
self.tr.close()
self.lost.set_result(None)
async def main():
async def handler(reader, writer):
writer.close()
srv = await asyncio.start_server(handler, '127.0.0.1', 0,
ssl=tu.simple_server_sslcontext())
port = srv.sockets[0].getsockname()[1]
loop = asyncio.get_running_loop()
proto = Proto()
proto.lost = loop.create_future()
tr, _ = await loop.create_connection(
lambda: proto, '127.0.0.1', port, ssl=tu.simple_client_sslcontext())
await proto.lost
tr.write(b'x') # AttributeError: 'NoneType' object has no attribute '_write_appdata'
srv.close()
asyncio.run(main())
set_protocol(), get_write_buffer_size() and get_extra_info() fail the same way. Plain TCP transports don't have this problem.
It also breaks the loop.sendfile() fallback over SSL: if the peer disconnects mid-transfer, restore() calls set_protocol() and raises AttributeError instead of the expected connection error.
The cause is in _SSLProtocolTransport.close(). When it's called on a transport already marked closed, it sets _ssl_protocol = None. That was added in gh-98539 so the transport doesn't keep the SSL context alive, but it leaves the transport unusable.
Affects 3.11 and later.
Linked PRs
- gh-160965
- 主要言語
- Python
- スター
- 77.8k
- フォーク
- 37.7k
- 平均マージ
- 17時間 24分
- マージ済み PR(30日)
- 716
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/cpython のほかの issue
-
build OS-unsupported OS-windows type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
メンテナーはふだん 1 日以内に返信
-
What's New in 3.12 credits the unstable C API tier to PEP 697 instead of PEP 689対応中かも @TheLouisMahdi が 1 日前に担当しました。 オープンdocs
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
python/cpython#161078 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
OS-windows type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
docs
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
python/cpython#161007 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
Null dereferencing of a pointer in initconfig.c対応中かも @lazerg が 4 日前に担当しました。 オープンinterpreter-core topic-C-API type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
python/cpython#160962 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
QuantConnect/Documentation#2838 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
awslabs/route53-dynamic-dns-with-lambda#67 · コメント 1 件 ·
-
`SubAgents` returns a child run's `DeferredToolRequests` to the parent as a successful tool resultオープンbug pkg:harness
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
pydantic/pydantic-ai#12405 ·
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
good first issue help wanted
難易度 1/5 1時間未満 初心者へのやさしさ 82/100