open() in binary vs. text mode

Bob Roberts bobnotbob at byu.edu
Fri Mar 21 14:45:05 EST 2003


Syver Enstad <syver-en+usenet at online.no> wrote in message news:<uadfpg9dg.fsf at online.no>...
> bobnotbob at byu.edu (Bob Roberts) writes:
> 
> > I just finished tracking down a cross-platorm bug.  The problem was
> > that I didn't open() a file in binary ("rb") mode.  What exactly does
> > the binary flag do on windows?  What is it's purpose?
> 
> On windows text files are written with \r\n (carriage return and
> linefeed) as the end of line marker. On Macintosh \r is the end of
....

This problem does not appear to have anything to do with the \r\n vs.
\r vs \n problem.

When in windows, reading in text mode, if it came across ASCII
character 26, it would quit and not read any more of the file.  This
does not happen on other platforms or on windows when reading in
binary mode.

Why would a specific character cause this behavior?




More information about the Python-list mailing list