Update IMAP.py

Return before decoding items of imapdata, None cannot be decoded.
This commit is contained in:
alessio-pascolini 2022-03-08 10:22:11 +01:00 committed by GitHub
parent e64c254072
commit 210c23bdee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: