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:
Łukasz Żarnowiecki
2016-05-17 19:56:52 +02:00
committed by Nicolas Sebrecht
parent 83539f8601
commit 0addcbabf0
13 changed files with 70 additions and 49 deletions

View File

@ -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)