Error on mimetools?

Robert Amesz reqhye72zux at mailexpire.com
Mon Jul 30 19:26:20 EDT 2001


Arnulf Heimsbakk wrote:

> I'm using only the raw base64 text. It is the same text I used in
> my winzip experiment and in python test program I've made. It works
> in winzip but not with python code. As I mentioned python gives me
> a file slightly bigger than winzip. It's about 300 bytes bigger.
> 
> I'm without clues to this one. It does not seem to be any logic in
> the error.

[You really should mention (among other things) the OS you're using, 
but as you posted your message with OE, I'll assume it's Windows.]

It sounds as if you might have openened a file in the text mode instead 
of the binary mode (or possibly the other way round). In Windows, 
saving a binary file in the text mode will cause spurious '\r' 
characters to be inserted into the stream for every '\n'. Be thankful 
you don't own a Mac: on that platform every '\n' is *replaced* by an 
'\r', depriving you of a valuable clue something is wrong.

Assuming the file consists of random characters, 1 in every 256 
characters will be a '\n', so the 300 extra bytes would indicate a file 
size of about 75000 bytes.

If this is the cause the remedy is simple: try finding an 
open(somefilename, 'w') in the code, and change the 'w' to 'wb'.


HTH,
Robert Amesz



More information about the Python-list mailing list