asyncio: SSL transport raises AttributeError after close() in connection_lost()
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- networking
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 77.8k
- Fork
- 37.7k
- Merge trung bình
- 17 giờ 2 phút
- Pull request đã merge (30 ngày)
- 699
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
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 python/cpython
-
build OS-unsupported OS-windows type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 60/100
Maintainer thường phản hồi trong vòng 1 ngày
-
What's New in 3.12 credits the unstable C API tier to PEP 697 instead of PEP 689Có thể đã có người làm @TheLouisMahdi đã nhận 2 ngày trước. Đang mởdocs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
python/cpython#161078 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
OS-windows type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
python/cpython#161007 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Null dereferencing of a pointer in initconfig.cCó thể đã có người làm @lazerg đã nhận 4 ngày trước. Đang mởinterpreter-core topic-C-API type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
python/cpython#160962 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của python/cpython
Issue tương tự
-
Backend issue lists report in-patch warnings and out-of-patch errors as not publishableCó thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
mozilla/code-review#3794 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[oblt-aw][autodoc] Update docs that still describe the security registry as emptyCó thể đã có người làm @github-actions đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] adb backup script reports "Done" & exits 0 when the backup failsCó thể đã có người làm @bhattmanthan đã nhận hôm nay. Đang mởrequest-issue-assignment
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
OWASP/mastg#4034 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent-ui bug p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
correction metadata
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
acl-org/acl-anthology#10768 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày