More bugs processing mail under python 3, on behalf of @spamandeggs for #590

This commit is contained in:
Garret Wassermann 2018-03-03 19:32:47 -05:00
parent 1406c2a719
commit 283f5e9cec

View File

@ -179,10 +179,11 @@ def process_queue(q, logger):
if six.PY2:
full_message = encoding.force_text("\n".join(server.retr(msgNum)[1]), errors='replace')
else:
popmsg = []
for line in server.retr(msgNum)[1]:
popmsg.append(line.encode())
full_message = encoding.force_text(b"\n".join(popmsg), errors='replace')
raw_content = server.retr(msgNum)[1]
if type(raw_content[0]) is bytes:
full_message = "\n".join([elm.decode('utf-8') for elm in raw_content])
else :
full_message = encoding.force_text("\n".join(raw_content), errors='replace')
ticket = ticket_from_message(message=full_message, queue=q, logger=logger)
if ticket: