From 18d2e972ac76c360a5c3c4e069c9ee643509d113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Sat, 29 Aug 2020 19:00:28 +0200 Subject: [PATCH] Mail now is typle of bytes convert to str This patch saves the tuple and discard the bytes/str (now bytes). Then, convert the tuple elements to str (from bytes). --- offlineimap/folder/IMAP.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/offlineimap/folder/IMAP.py b/offlineimap/folder/IMAP.py index 7979b7c..9ffbdae 100644 --- a/offlineimap/folder/IMAP.py +++ b/offlineimap/folder/IMAP.py @@ -814,7 +814,7 @@ class IMAPFolder(BaseFolder): # 'data' (the BODY response appears as a tuple). This should leave # exactly one response. if res_type == 'OK': - data = [res for res in data if not isinstance(res, str)] + data = [res for res in data if not isinstance(res, bytes)] # Could not fetch message. Note: it is allowed by rfc3501 to return any # data for the UID FETCH command. @@ -829,7 +829,12 @@ class IMAPFolder(BaseFolder): "with UID '%s'"% (self.getrepository(), uids) raise OfflineImapError(reason, severity) - return data + # Convert bytes to str + ndata0 = data[0][0].decode('utf-8') + ndata1 = data[0][1].decode('utf-8') + ndata = [ndata0, ndata1] + + return ndata def _store_to_imap(self, imapobj, uid, field, data):