From 41c2ced1d5618744d2dbd9260e3ed5a686115132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Tue, 1 Sep 2020 19:07:52 +0200 Subject: [PATCH] IMAP.py _msgs_to_fetch decode bytes 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 --- offlineimap/folder/IMAP.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 78e0621..b4d279c 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -230,7 +230,14 @@ class IMAPFolder(BaseFolder): res_data.remove(0) return res_data - res_type, imapdata = imapobj.select(self.getfullIMAPname(), True, True) + a = self.getfullIMAPname() + res_type, imapdata = imapobj.select(a, True, True) + + # 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