IMAP: Python 3 bytes fix on first download of account

ERROR: ERROR in syncfolder for gmail folder INBOX: Traceback (most recent call last):
  File ".../offlineimap3/offlineimap/accounts.py", line 634, in syncfolder
    cachemessagelists_upto_date(maxage)
  File ".../offlineimap3/offlineimap/accounts.py", line 526, in cachemessagelists_upto_date
    min_date=time.gmtime(time.mktime(date) + 24 * 60 * 60))
  File ".../offlineimap3/offlineimap/folder/IMAP.py", line 277, in cachemessagelist
    imapobj, min_date=min_date, min_uid=min_uid)
  File ".../offlineimap3/offlineimap/folder/IMAP.py", line 259, in _msgs_to_fetch
    search_result = search(search_cond)
  File ".../offlineimap3/offlineimap/folder/IMAP.py", line 222, in search
    if ' ' in res_data[0] or res_data[0] == '':
TypeError: a bytes-like object is required, not 'str'
This commit is contained in:
Thomas De Schampheleire 2020-10-21 14:25:48 +02:00
parent 4c46cffcc8
commit 820e5c855f

View File

@ -219,7 +219,7 @@ class IMAPFolder(BaseFolder):
OfflineImapError.ERROR.FOLDER) OfflineImapError.ERROR.FOLDER)
# Davmail returns list instead of list of one element string. # Davmail returns list instead of list of one element string.
# On first run the first element is empty. # On first run the first element is empty.
if ' ' in res_data[0] or res_data[0] == '': if b' ' in res_data[0] or res_data[0] == b'':
res_data = res_data[0].split() res_data = res_data[0].split()
# Some servers are broken. # Some servers are broken.
if 0 in res_data: if 0 in res_data: