[PATCH] fix socket.ssl() deprecation with respect to older versions
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
* there should really be a VERSION macro for that kind of stuff...
Signed-off-by: Christoph Höger <choeger@xxxxxxxxxxxxxxx>
---
offlineimap/imaplibutil.py | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/offlineimap/imaplibutil.py b/offlineimap/imaplibutil.py
index 27ed1fa..5e246c2 100644
--- a/offlineimap/imaplibutil.py
+++ b/offlineimap/imaplibutil.py
@@ -23,6 +23,9 @@ from imaplib import *
# Import the symbols we need that aren't exported by default
from imaplib import IMAP4_PORT, IMAP4_SSL_PORT, InternalDate, Mon2num
+# ssl is new in python 2.6
+if (sys.version_info[0] == 2 and sys.version_info[1] >= 6) or
sys.version_info[0] >= 3:
+ import ssl
class IMAP4_Tunnel(IMAP4):
"""IMAP4 client class over a tunnel
@@ -166,8 +169,16 @@ def new_open_ssl(self, host = '', port = IMAP4_SSL_PORT):
if last_error != 0:
# FIXME
raise socket.error(last_error)
- self.sslobj = socket.ssl(self.sock, self.keyfile, self.certfile)
- self.sslobj = sslwrapper(self.sslobj)
+
+ # since 2.6 socket.ssl is deprecated
+ if (sys.version_info[0] == 2 and sys.version_info[1] >= 6) or
sys.version_info[0] >= 3:
+ # following deprecation suggestion
+ self.sslobj = sslwrapper(ssl.wrap_socket(self.sock,
+ self.keyfile, self.certfile))
+ else:
+ # fall back for older versions
+ self.sslobj = socket.ssl(self.sock, self.keyfile, self.certfile)
+ self.sslobj = sslwrapper(self.sslobj)
mustquote = re.compile(r"[^\w!#$%&'+,.:;<=>?^`|~-]")
--
1.6.2.5
-- Attached file included as plaintext by Ecartis --
-- File: signature.asc
-- Desc: Dies ist ein digital signierter Nachrichtenteil
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEABECAAYFAkpGK3IACgkQhMBO4cVSGS+jVgCfVisFZHrzBPjGxd+KuoNReRqc
QeAAoK+e49hlDCXEKKjMQL8So2VoZWcH
=MUqO
-----END PGP SIGNATURE-----
- [PATCH] fix socket.ssl() deprecation with respect to older versions,
Christoph Höger <=
|
|