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.
This commit is contained in:
Rodolfo García Peñas (kix) 2021-07-25 02:26:07 +02:00
parent a6fd6b1ded
commit 09fc0ece61

View File

@ -72,7 +72,18 @@ class OfflineImap:
""" """
def get_env_info(self): 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: try:
import ssl import ssl
info = "%s, %s" % (info, ssl.OPENSSL_VERSION) info = "%s, %s" % (info, ssl.OPENSSL_VERSION)