From 09fc0ece618a55040699474480db0decaf921aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Sun, 25 Jul 2021 02:26:07 +0200 Subject: [PATCH] imaplib2 version function The new imaplib2 version >= 3.06 includes a function "version()", and this patch uses the old style __version__ value and the new function. This patch is related to issue #37, issue 2. --- offlineimap/init.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/offlineimap/init.py b/offlineimap/init.py index 9f9592e..ca6c26f 100644 --- a/offlineimap/init.py +++ b/offlineimap/init.py @@ -72,7 +72,18 @@ class OfflineImap: """ def get_env_info(self): - info = "imaplib2 v%s, Python v%s" % (imaplib.__version__, PYTHON_VERSION) + # Transitional code between imaplib2 versions + try: + # imaplib2, previous versions, based on Python 2.x + l_imaplib_version = imaplib.__version__ + except AttributeError: + # New imaplib2, version >= 3.06 + l_imaplib_version = imaplib.version() + except: + # This should not happen + l_imaplib_version = " Unknown" + + info = "imaplib2 v%s, Python v%s" % (l_imaplib_version, PYTHON_VERSION) try: import ssl info = "%s, %s" % (info, ssl.OPENSSL_VERSION)