Re: Newline interpretation issue with MIMEApplication with binary data, Python 3.3.2

2013-09-26 Thread Piet van Oostrum
Nils Bunger writes: > Hi Neil, > > Thanks for looking at this. > > I'm trying to create a multipart MIME for an HTTP POST request, not an > email. This is for a third-party API that requires a multipart POST > with a binary file, so I don't have the option to just use a different > encoding. >

Re: Newline interpretation issue with MIMEApplication with binary data, Python 3.3.2

2013-09-26 Thread Nils Bunger
Hi all, I was able to workaround this problem by encoding a unique 'marker' in the binary part, then replacing the marker with the actual binary content after generating the MIME message. See my answer on Stack Overflow http://stackoverflow.com/a/19033750/526098 for the code. Thanks, your s

Re: Newline interpretation issue with MIMEApplication with binary data, Python 3.3.2

2013-09-26 Thread Nils Bunger
Hi Neil, Thanks for looking at this. I'm trying to create a multipart MIME for an HTTP POST request, not an email. This is for a third-party API that requires a multipart POST with a binary file, so I don't have the option to just use a different encoding. Multipart HTTP is standardized in

Re: Newline interpretation issue with MIMEApplication with binary data, Python 3.3.2

2013-09-26 Thread Neil Cerutti
On 2013-09-26, Chris Angelico wrote: > On Thu, Sep 26, 2013 at 2:23 PM, Nils Bunger wrote: >> Yes, it's email.mime.MIMEApplication. I've pasted a snippet >> with the imports below. >> >> I'm trying to use this to build a multi-part MIME message, >> with this as one part. >> >> I really can't figu

Re: Newline interpretation issue with MIMEApplication with binary data, Python 3.3.2

2013-09-25 Thread Chris Angelico
On Thu, Sep 26, 2013 at 2:23 PM, Nils Bunger wrote: > Yes, it's email.mime.MIMEApplication. I've pasted a snippet with the imports > below. > > I'm trying to use this to build a multi-part MIME message, with this as one > part. > > I really can't figure out any way to attach a binary part like t

Re: Newline interpretation issue with MIMEApplication with binary data, Python 3.3.2

2013-09-25 Thread Nils Bunger
Chris, Thanks for answering. Yes, it's email.mime.MIMEApplication. I've pasted a snippet with the imports below. I'm trying to use this to build a multi-part MIME message, with this as one part. I really can't figure out any way to attach a binary part like this to a multi-part MIME messa

Re: Newline interpretation issue with MIMEApplication with binary data, Python 3.3.2

2013-09-25 Thread Chris Angelico
On Thu, Sep 26, 2013 at 2:38 AM, wrote: > app = MIMEApplication(b'Q\x0dQ', _encoder=encode_noop) What is MIMEApplication? It's not a builtin, so your test case is missing an import, at least. Is this email.mime.MIMEApplication? ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Newline interpretation issue with MIMEApplication with binary data, Python 3.3.2

2013-09-25 Thread 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