[Python-Dev] file read-ahead with Mac end-of-line
Guido van Rossum
guido at python.org
Sun Aug 17 15:05:30 EDT 2003
> The patch below fixes my csv module problem, but I wonder
> if it's the correct fix. Suppose you're using Mac line endings and
> encounter a \n before a \r? This function will return a too-short line.
> (Of course, it would without the patch as well.)
> I don't know how (or if) this should work with universal newline support.
> We expect files to be opened in binary mode, so I don't know if universal
> newline support applies.
> In short, does this look like the correct patch, closer to the correct
> behavior than the current setup, or no improvement at all?
I'm not familiar with the csv module, but if it opens the file in
binary mode, readline() and next() are *required* to only honor \n as
the line end character. Maybe the csv module ought to open the file
in universal newline mode (f = open(filename, "U")?
The patch you give would make next() behave like universal newline
mode in all modes, which is definitely wrong.
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev