From 91eea339e8326679f65ce2650127463a6e637b1f Mon Sep 17 00:00:00 2001 From: Menno Smits Date: Fri, 23 Jan 2015 23:35:55 +1300 Subject: [PATCH] moved the internal _SSLConnection class further down the file --- imapclient/tls.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/imapclient/tls.py b/imapclient/tls.py index ed1127c..895ad20 100644 --- a/imapclient/tls.py +++ b/imapclient/tls.py @@ -95,20 +95,8 @@ def get_default_context(cafile=None, capath=None, check_hostname=True): return context -class _SSLConnection(SSL.Connection): - """Wrapper for OpenSSL.SSL.Connection for socket compatibility.""" - - def shutdown(self, *args): - # Fix method signature incompatibility bewteen pyOpenSSL.SSL.Connection - # and socket.socket - SSL.Connection.shutdown(self) - - def makefile(self, mode='rb', *args, **kwargs): - # Support only arguments needed by imaplib - return _socketfileobj(self, mode) - - class IMAP4(imaplib.IMAP4): + def starttls(self, ssl_context=None): """Send a STARTTLS command and wrap the socket with TLS.""" name = 'STARTTLS' @@ -147,6 +135,19 @@ class IMAP4(imaplib.IMAP4): return self._untagged_response(type_, dat, name) +class _SSLConnection(SSL.Connection): + """Wrapper for OpenSSL.SSL.Connection for socket compatibility.""" + + def shutdown(self, *args): + # Fix method signature incompatibility bewteen pyOpenSSL.SSL.Connection + # and socket.socket + SSL.Connection.shutdown(self) + + def makefile(self, mode='rb', *args, **kwargs): + # Support only arguments needed by imaplib + return _socketfileobj(self, mode) + + # lifted from backports.ssl class _socketfileobj(object): """Custom file-like object to support socket.makefile for pyOpenSSL.""" -- 2.43.0