From 845499cbb62b95e07e790fbbde47d33449e78181 Mon Sep 17 00:00:00 2001 From: kenneth topp Date: Wed, 21 Sep 2022 22:38:51 -0400 Subject: [PATCH] Handle SSLZeroReturnError exceptions Python 3.8 introduced a different exception for zero byte tcp connections. These connections are generated by cherrypy on startup, and so the exception is not displayed as it is expected. Without this fix an exception is displayed although it is harmless. This treats the new exception just like it was treated under the errno exception. --- cheroot/ssl/builtin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cheroot/ssl/builtin.py b/cheroot/ssl/builtin.py index b22d4ae611..0e1d4424f6 100644 --- a/cheroot/ssl/builtin.py +++ b/cheroot/ssl/builtin.py @@ -270,6 +270,11 @@ def wrap(self, sock): s = self.context.wrap_socket( sock, do_handshake_on_connect=True, server_side=True, ) + except ssl.SSLZeroReturnError: + # This is almost certainly due to the cherrypy engine + # 'pinging' the socket to assert it's connectable; + # the 'ping' isn't SSL. + return EMPTY_RESULT except ssl.SSLError as ex: if ex.errno == ssl.SSL_ERROR_EOF: # This is almost certainly due to the cherrypy engine