From 210c23bdee9acd852c0bea02887431b630359418 Mon Sep 17 00:00:00 2001 From: alessio-pascolini Date: Tue, 8 Mar 2022 10:22:11 +0100 Subject: [PATCH] Update IMAP.py Return before decoding items of imapdata, None cannot be decoded. --- offlineimap/folder/IMAP.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index c9318c2..5bc091c 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -243,15 +243,15 @@ class IMAPFolder(BaseFolder): a = self.getfullIMAPname() res_type, imapdata = imapobj.select(a, True, True) + if imapdata == [None] or imapdata[0] == b'0': + # Empty folder, no need to populate message list. + return None + # imaplib2 returns the type as string, like "OK" but # returns imapdata as list of bytes, like [b'0'] so we need decode it # to use the existing code imapdata = [x.decode('utf-8') for x in imapdata] - - if imapdata == [None] or imapdata[0] == '0': - # Empty folder, no need to populate message list. - return None - + conditions = [] # 1. min_uid condition. if min_uid is not None: