From 0906d0db7062b37d68a9998045880d09d5222f70 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Mon, 5 Sep 2011 14:03:09 +0200 Subject: [PATCH] IMAP.cachemessagelist(): Protect against empty folders When invoked with FETCH 1:* (UID), imaplib returns [None] for empty folders. We need to protect against this case and simply 'continue' here. Signed-off-by: Sebastian Spaeth Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/IMAP.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index ac18d69..2774136 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -181,8 +181,10 @@ class IMAPFolder(BaseFolder): finally: self.imapserver.releaseconnection(imapobj) for messagestr in response: - # looks like: '1 (FLAGS (\\Seen Old) UID 4807)' + # looks like: '1 (FLAGS (\\Seen Old) UID 4807)' or None if no msg # Discard initial message number. + if messagestr == None: + continue messagestr = messagestr.split(' ', 1)[1] options = imaputil.flags2hash(messagestr) if not options.has_key('UID'):