From 36375daee67e8dd1a8256abec6798618f4e05061 Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Fri, 19 Feb 2016 12:33:57 +0100 Subject: [PATCH] fix: exceptions.OSError might not have attribute EEXIST defined Since this is used in an except calse, we first don't mask the real cause and raise the original error. Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/Maildir.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py index 64570a1..7d188b5 100644 --- a/offlineimap/folder/Maildir.py +++ b/offlineimap/folder/Maildir.py @@ -292,7 +292,8 @@ class MaildirFolder(BaseFolder): that was created.""" tmpname = os.path.join('tmp', filename) - # open file and write it out + # Open file and write it out. + # XXX: why do we need to loop 7 times? tries = 7 while tries: tries = tries - 1 @@ -301,6 +302,8 @@ class MaildirFolder(BaseFolder): os.O_EXCL|os.O_CREAT|os.O_WRONLY, 0o666) break except OSError as e: + if not hasattr(e, 'EEXIST'): + raise if e.errno == e.EEXIST: if tries: time.sleep(0.23)