Error on mimetools?

Martin von Loewis loewis at informatik.hu-berlin.de
Mon Jul 30 08:47:52 EDT 2001


"Arnulf Heimsbakk" <arnulf at spirea.net> writes:

> I'm trying to decode a mime64 message in python with mimetools. I have
> tested the "body" with windows winzip. It decodes correctly. When I try to
> decode it in python, it do not decode correctly. I get a file with slightly
> increased size. The heading of the file seems the same, but when I test this
> with a jpg file - the file gets corrupted when decoded with python's
> mimetools.
> 
> Is there a error in mimetools? Or is my approach entirly incorrect. My code
> is below:
> 
> out = StringIO()
> mimetools.decode(StringIO(self.body), out,  'base64')
> return out.getvalue()

It very much depends on what self.body is in this context. To use
mimetools.decode, you must be sure that it is the raw base64 bytes,
i.e. without any headers and trailers.

Regards,
Martin




More information about the Python-list mailing list