diff --git a/src/anyio/_core/_sockets.py b/src/anyio/_core/_sockets.py index 438b04ee..801182f1 100644 --- a/src/anyio/_core/_sockets.py +++ b/src/anyio/_core/_sockets.py @@ -237,12 +237,12 @@ async def try_connect(remote_host: str, event: Event) -> None: oserrors[0] if len(oserrors) == 1 else ExceptionGroup( - "multiple connection attempts failed", oserrors.copy() + "multiple connection attempts failed", oserrors ) ) raise OSError("All connection attempts failed") from cause finally: - oserrors.clear() + del oserrors if tls or tls_hostname or ssl_context: try: