[issue4847] csv fails when file is opened in binary mode

John Machin report at bugs.python.org
Mon Mar 9 07:02:16 CET 2009


John Machin <sjmachin at users.sourceforge.net> added the comment:

Before patching, could we discuss the requirements?

There are two different concepts:
(1) "text" file (assume that CR and/or LF are line terminators, and
provide methods for accessing a line at a time) versus "binary" file (no
such assumptions, no such access)
(2) reading the file as a raw undecoded "bytes" file or as a decoded
"str" file.

Options for 3.X:
(1) caller uses mode 'rb', is given bytes objects back.
(2) caller uses mode 'rt' and provides an encoding, is given str objects
back.
IMPORTANT: Option 2 must NOT not read the file as a collection of
"lines"; it must process it (conceptually at least) a character at a
time so that embedded CR and/or LF are not taken to be row terminators.

Following the line that 3.X line should do what's best, not what we used
to do, the implication is that we choose option 2.

----------
message_count: 10.0 -> 11.0
nosy: +skip.montanaro
nosy_count: 6.0 -> 7.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4847>
_______________________________________


More information about the Python-bugs-list mailing list