IMAP.py: server responses are in bytes, not string
Following error is seen when parsing server responses for sent mail: 2020-10-12 08:19:11 WARNING: Can't parse FETCH response, we awaited string: b' UID 26855)' 2020-10-12 08:19:11 WARNING: savemessage: Searching mails for new Message-ID failed. Could not determine new UID on Sent. The comparison with 'type("")' means comparing with 'string' type in Python 3, but the left-hand side is a bytes object. In case a tuple was received (first case in the code), the input is already decoded from bytes to strings, but in case a single input was received it was not. Note that the comparison with 'type("")' is a bit odd, a more logical way seems to be: if isinstance(item, bytes) Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
This commit is contained in:
parent
941d69c7b4
commit
423785725b
@ -482,7 +482,8 @@ class IMAPFolder(BaseFolder):
|
|||||||
item[1], flags=re.IGNORECASE):
|
item[1], flags=re.IGNORECASE):
|
||||||
found = item[0]
|
found = item[0]
|
||||||
elif found is not None:
|
elif found is not None:
|
||||||
if type(item) == type(""):
|
if type(item) == type(b""):
|
||||||
|
item = item.decode('utf-8')
|
||||||
uid = re.search("UID\s+(\d+)", item, flags=re.IGNORECASE)
|
uid = re.search("UID\s+(\d+)", item, flags=re.IGNORECASE)
|
||||||
if uid:
|
if uid:
|
||||||
return int(uid.group(1))
|
return int(uid.group(1))
|
||||||
|
Loading…
Reference in New Issue
Block a user