From caf9f9983a43c537efff5c4c9ff1d543af6e1220 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Wed, 21 Dec 2022 09:32:44 +0100 Subject: [PATCH] Change ssl to return a socket.timeout exception on timeout instead of an SSLError Back in Python 3.2, ssl.SSLError used to be a subclass of socket.error (see https://docs.python.org/3/library/ssl.html#exceptions), so timeouts on monkeypatched ssl sockets would be properly caught by socket.timeout excpetion handlers in applications. However, since Python 3.3 ssl.SSLerror is a subclass of OSError, which signifies a different (typically fatal) type of error that is usually not handled gracefully by applications. By changing the timeout excpetion back to socket.timeout, libraries such as pymysql and redis will again properly support TLS-connections in monkeypatched apoplications. --- eventlet/green/ssl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eventlet/green/ssl.py b/eventlet/green/ssl.py index b42ddaa64..be4f29b57 100644 --- a/eventlet/green/ssl.py +++ b/eventlet/green/ssl.py @@ -15,7 +15,7 @@ orig_socket = __import__('socket') socket = orig_socket.socket -timeout_exc = SSLError +timeout_exc = orig_socket.timeout __patched__ = [ 'SSLSocket', 'SSLContext', 'wrap_socket', 'sslwrap_simple',