Issue #23197, asyncio: On SSL handshake failure, check if the waiter is
cancelled before setting its exception.

* Add unit tests for this case.
* Cleanup also sslproto.py
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index b2f29c7..ca86264 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -750,7 +750,7 @@
             self._loop.remove_reader(self._sock_fd)
             self._loop.remove_writer(self._sock_fd)
             self._sock.close()
-            if self._waiter is not None:
+            if self._waiter is not None and not self._waiter.cancelled():
                 self._waiter.set_exception(exc)
             if isinstance(exc, Exception):
                 return