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

@ -23,6 +23,8 @@ from offlineimap import OfflineImapError
import offlineimap.accounts
from offlineimap import imaputil
import six
class GmailMaildirFolder(MaildirFolder):
"""Folder implementation to support adding labels to messages in a Maildir.
"""
@ -170,9 +172,8 @@ class GmailMaildirFolder(MaildirFolder):
try:
os.rename(tmppath, filepath)
except OSError as e:
raise OfflineImapError("Can't rename file '%s' to '%s': %s" % \
(tmppath, filepath, e[1]), OfflineImapError.ERROR.FOLDER), \
None, exc_info()[2]
six.reraise(OfflineImapError("Can't rename file '%s' to '%s': %s" % \
(tmppath, filepath, e[1]), OfflineImapError.ERROR.FOLDER), None, exc_info()[2])
# if utime_from_header=true, we don't want to change the mtime.
if self.utime_from_header and mtime: