asyncio: SSL transport raises AttributeError after close() in connection_lost()
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- networking
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 77.8k
- Fork
- 37.7k
- Merge medio
- 17h 2m
- PR unite (30g)
- 699
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python/cpython
-
build OS-unsupported OS-windows type-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 60/100
I maintainer di solito rispondono entro 1 giorno
-
What's New in 3.12 credits the unstable C API tier to PEP 697 instead of PEP 689Forse già presa @TheLouisMahdi l’ha presa 2 giorni fa. Apertadocs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
python/cpython#161078 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
OS-windows type-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
docs
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
python/cpython#161007 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Null dereferencing of a pointer in initconfig.cForse già presa @lazerg l’ha presa 4 giorni fa. Apertainterpreter-core topic-C-API type-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
python/cpython#160962 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di python/cpython
Issue simili
-
Backend issue lists report in-patch warnings and out-of-patch errors as not publishableForse già presa @RaphaelFakhri l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
mozilla/code-review#3794 ·
I maintainer di solito rispondono entro 1 giorno
-
[oblt-aw][autodoc] Update docs that still describe the security registry as emptyForse già presa @github-actions l’ha presa oggi. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug] adb backup script reports "Done" & exits 0 when the backup failsForse già presa @bhattmanthan l’ha presa oggi. Apertarequest-issue-assignment
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
OWASP/mastg#4034 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
agent-ui bug p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
correction metadata
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
acl-org/acl-anthology#10768 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno