N
nilsbunger
Hi,
I'm having trouble encoding a MIME message with a binary file. Newline characters are being interpreted even though the content is supposed to be binary. This is using Python 3.3.2
Small test case:
app = MIMEApplication(b'Q\x0dQ', _encoder=encode_noop)
b = io.BytesIO()
g = BytesGenerator(b)
g.flatten(app)
for i in b.getvalue()[-3:]:
print ("%02x " % i, end="")
print ()
This prints 51 0a 51, meaning the 0x0d character got reinterpreted as a newline.
I've tried setting an email policy of HTTP policy, but that goes even further, converting \r to \r\n
This is for HTTP transport, so binary encoding is normal.
Any thoughts how I can do this properly?
I'm having trouble encoding a MIME message with a binary file. Newline characters are being interpreted even though the content is supposed to be binary. This is using Python 3.3.2
Small test case:
app = MIMEApplication(b'Q\x0dQ', _encoder=encode_noop)
b = io.BytesIO()
g = BytesGenerator(b)
g.flatten(app)
for i in b.getvalue()[-3:]:
print ("%02x " % i, end="")
print ()
This prints 51 0a 51, meaning the 0x0d character got reinterpreted as a newline.
I've tried setting an email policy of HTTP policy, but that goes even further, converting \r to \r\n
This is for HTTP transport, so binary encoding is normal.
Any thoughts how I can do this properly?