From 41e65f5ef853068053f08da8fdd6c8b08e85b6fa Mon Sep 17 00:00:00 2001 From: Menno Finlay-Smits Date: Sat, 28 Oct 2023 07:41:58 +1300 Subject: [PATCH] Remove SSL compatibility code for Python 2 --- imapclient/tls.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/imapclient/tls.py b/imapclient/tls.py index fa97c555..fe9671e1 100644 --- a/imapclient/tls.py +++ b/imapclient/tls.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015, Menno Smits +# Copyright (c) 2023, Menno Smits # Released subject to the New BSD License # Please see http://en.wikipedia.org/wiki/BSD_licenses @@ -20,18 +20,6 @@ def wrap_socket( sock: socket.socket, ssl_context: Optional[ssl.SSLContext], host: str ) -> socket.socket: - if not hasattr(ssl, "create_default_context"): - # Python 2.7.0 - 2.7.8 do not have the concept of ssl contexts. - # Thus we have to use the less flexible and legacy way of wrapping the - # socket - if ssl_context is not None: - raise RuntimeError( - "Cannot precisely configure the SSL connection, upgrade to " - "Python >= 2.7.9 to fine tune the settings." - ) - - return ssl.wrap_socket(sock) - if ssl_context is None: ssl_context = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH)