You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix email interfaces with Python 3 (issue 2550974, issue 2551000).
This patch fixes various issues handling incoming email with
roundup-mailgw with Python 3.
Incoming email must always be handled as bytes, not strings, because
it may contain 8-bit-encoded MIME parts with different encodings in
each part. When handling piped input, that means using
sys.stdin.buffer in Python 3 for binary input, along with
message_from_binary_file, not sys.stdin which is text input and may be
for the wrong encoding and not message_from_file. (In turn, tests
that use MailGW.main with text input are affected so an s2b call is
inserted in the test code and it is made to use BytesIO not StringIO.
Properly all the test messages in test_mailgw.py ought to use b''
explicitly rather than having such an s2b conversion, and there ought
to be test messages using 8-bit encodings with non-ASCII characters to
verify that that case works.)
imaplib and poplib return bytes not strings with Python 3 (from
inspection of the code, not tested), as is necessary for the above
reasons. Thus, the handling of IMAP and POP messages must expect
bytes and handle the data accordingly.
For messages from mailboxes, I saw the same problem described in issue
2551000 for a multipart message with a single (non-ASCII) part. The
Roundup code requires RoundupMessage not email.message.Message to be
used recursively for all MIME parts of a message. Because the mailbox
module uses email.message_from_* directly without passing the _class
argument to them, fixing this requires temporarily patching the email
module to ensure _class=RoundupMessage gets passed to those methods.
0 commit comments