correctly reraise errors with six

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht
2016-06-29 03:42:57 +02:00
parent 69c0080323
commit 7945e10a76
13 changed files with 139 additions and 86 deletions

View File

@ -228,9 +228,12 @@ class SyncableAccount(Account):
pass
except IOError:
self._lockfd.close()
six.reraise(OfflineImapError("Could not lock account %s. Is another "
"instance using this account?"% self,
OfflineImapError.ERROR.REPO), None, exc_info()[2])
six.reraise(OfflineImapError,
OfflineImapError(
"Could not lock account %s. Is another "
"instance using this account?"% self,
OfflineImapError.ERROR.REPO),
exc_info()[2])
def _unlock(self):
"""Unlock the account, deleting the lock file"""
@ -552,10 +555,12 @@ def syncfolder(account, remotefolder, quick):
localstart = localfolder.getstartdate()
remotestart = remotefolder.getstartdate()
if (maxage != None) + (localstart != None) + (remotestart != None) > 1:
six.reraise(OfflineImapError("You can set at most one of the "
"following: maxage, startdate (for the local folder), "
"startdate (for the remote folder)",
OfflineImapError.ERROR.REPO), None, exc_info()[2])
six.reraise(OfflineImapError,
OfflineImapError("You can set at most one of the "
"following: maxage, startdate (for the local "
"folder), startdate (for the remote folder)",
OfflineImapError.ERROR.REPO),
exc_info()[2])
if (maxage != None or localstart or remotestart) and quick:
# IMAP quickchanged isn't compatible with options that
# involve restricting the messagelist, since the "quick"