py3: raise exceptions using six module
There is no other way to make Python2 and Python3 happy, because syntax raise E, V, T is incompatible with the latter. Signed-off-by: Łukasz Żarnowiecki <dolohow@outlook.com> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:

committed by
Nicolas Sebrecht

parent
83539f8601
commit
0addcbabf0
@ -27,6 +27,8 @@ from offlineimap.folder.UIDMaps import MappedIMAPFolder
|
||||
from offlineimap.threadutil import ExitNotifyThread
|
||||
from offlineimap.utils.distro import get_os_sslcertfile, get_os_sslcertfile_searchpath
|
||||
|
||||
import six
|
||||
|
||||
|
||||
class IMAPRepository(BaseRepository):
|
||||
def __init__(self, reposname, account):
|
||||
@ -107,9 +109,8 @@ class IMAPRepository(BaseRepository):
|
||||
try:
|
||||
host = self.localeval.eval(host)
|
||||
except Exception as e:
|
||||
raise OfflineImapError("remotehosteval option for repository "
|
||||
"'%s' failed:\n%s"% (self, e), OfflineImapError.ERROR.REPO), \
|
||||
None, exc_info()[2]
|
||||
six.reraise(OfflineImapError("remotehosteval option for repository "
|
||||
"'%s' failed:\n%s"% (self, e), OfflineImapError.ERROR.REPO), None, exc_info()[2])
|
||||
if host:
|
||||
self._host = host
|
||||
return self._host
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
from sys import exc_info
|
||||
|
||||
import six
|
||||
|
||||
try:
|
||||
from configparser import NoSectionError
|
||||
except ImportError: #python2
|
||||
@ -68,16 +70,14 @@ class Repository(object):
|
||||
except NoSectionError as e:
|
||||
errstr = ("Could not find section '%s' in configuration. Required "
|
||||
"for account '%s'." % ('Repository %s' % name, account))
|
||||
raise OfflineImapError(errstr, OfflineImapError.ERROR.REPO), \
|
||||
None, exc_info()[2]
|
||||
six.reraise(OfflineImapError(errstr, OfflineImapError.ERROR.REPO), None, exc_info()[2])
|
||||
|
||||
try:
|
||||
repo = typemap[repostype]
|
||||
except KeyError:
|
||||
errstr = "'%s' repository not supported for '%s' repositories."% \
|
||||
(repostype, reqtype)
|
||||
raise OfflineImapError(errstr, OfflineImapError.ERROR.REPO), \
|
||||
None, exc_info()[2]
|
||||
six.reraise(OfflineImapError(errstr, OfflineImapError.ERROR.REPO), None, exc_info()[2])
|
||||
|
||||
return repo(name, account)
|
||||
|
||||
|
Reference in New Issue
Block a user