From d66ae93c932d50e597241bb9bc4a6f1aef53004e Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sun, 9 Jul 2023 01:58:10 +0100 Subject: [PATCH] Fix transport is None error (#7333) Co-authored-by: Sviatoslav Sydorenko (cherry picked from commit 3a54d3785e4b314ca70aaafbee5b3ae8d409c18e) --- CHANGES/3355.bugfix | 1 + aiohttp/connector.py | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 CHANGES/3355.bugfix diff --git a/CHANGES/3355.bugfix b/CHANGES/3355.bugfix new file mode 100644 index 00000000000..fd002cb00df --- /dev/null +++ b/CHANGES/3355.bugfix @@ -0,0 +1 @@ +Fixed a transport is :data:`None` error -- by :user:`Dreamsorcerer`. diff --git a/aiohttp/connector.py b/aiohttp/connector.py index ea58d4cd193..a3a33f549df 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -1130,6 +1130,9 @@ async def _start_tls_connection( f"[{type_err!s}]" ) from type_err else: + if tls_transport is None: + msg = "Failed to start TLS (possibly caused by closing transport)" + raise client_error(req.connection_key, OSError(msg)) tls_proto.connection_made( tls_transport ) # Kick the state machine of the new TLS protocol