open() in binary vs. text mode

Bob Roberts bobnotbob at
Fri Mar 21 20:45:05 CET 2003

Syver Enstad <syver-en+usenet at> wrote in message news:<uadfpg9dg.fsf at>...
> bobnotbob at (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