From 8d45f9c99511cd80140d6658bd9c11002c697f1c Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 9 Jul 2023 01:35:28 +0000 Subject: [PATCH] [PR #7333/3a54d378 backport][3.8] Fix TLS transport is `None` error (#7357) Co-authored-by: Sam Bull Fixes #3355 --- 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 bf40689d81b..2499a2dabe9 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -1121,6 +1121,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