Character set woes with binary data

Michael B. Trausch fd0man at gmail.com
Sun Apr 1 13:52:30 EDT 2007


On Sun, 2007-04-01 at 06:09 -0300, Gabriel Genellina wrote: 

> > When putting the MIME segments (listed line-by-line in a Python list)
> > together to transmit them.  The files are typically JPG or some other
> > binary format, and as best as I understand the protocol, the binary data
> > needs to be transmitted directly (this is evidenced by looking at the
> > tcp-stream of an existing client for uploading files).
> 
> But I think your problem has nothing to do with MIME: you are mixing  
> unicode and string objects; from your traceback, either the "L" list or  
> "eol" contain unicode objects that can't be represented as ASCII strings.
> 


I never said it did.  It just happens to be the context with which I am
working.  I said I wanted to concatenate materials without regard for
the character set.  I am mixing binary data with ASCII and Unicode, for
sure, but I should be able to do this.

The current source can be found at
http://fd0man.theunixplace.com/scrapbook.py which is the version that I
am having the problem with.


> > It seems that Python thinks it knows better than I do, though.  I want
> > to send this binary data straightaway to the server.  :-)
> 
> You don't appear to be using the standard email package (which includes  
> MIME support) so don't blame Python...
> 


I am not saying anything about Python's standard library.  Furthermore,
I am not using MIME e-mail.  The MIME component that I am using, which
should be ideal for me, builds the message just fine—when not using a
binary component.  I am looking for how to tell Python to combine these
objects as nothing more than a stream of bytes, without regard for what
is inside the bytes.  That is what I was asking.  You did not tell me
how to do that, or if that is even possible, so why flame me?  I am not
saying "Python is bad, evil!" and blaming it for my ignorance, but what
I am asking for is how to accomplish what I am attempting to accomplish.
The MIME component is a (slightly modified) version of the recipe
provided from the ASPN Python Cookbook.

In short:  How do I create a string that contains raw binary content
without Python caring?  Is that possible?

    Thanks,
    Mike


> -- 
> Gabriel Genellina
> 


--
Michael B. Trausch
                    fd0man at gmail.com
Phone: (404) 592-5746
                          Jabber IM:
                    fd0man at gmail.com
              fd0man at livejournal.com
Demand Freedom!  Use open and free protocols, standards, and software!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070401/3cbdec69/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20070401/3cbdec69/attachment.sig>


More information about the Python-list mailing list