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

Skip Montanaro report at bugs.python.org
Thu Apr 2 19:55:27 CEST 2009


Skip Montanaro <skip at pobox.com> added the comment:

David> I've added some unit tests for embedded newlines, and py3k csv
    David> passes (on linux at least) when newline='' is used.  Unless
    David> someone can provide a test case that fails when newline='' is
    David> used, I propose we fix the documentation and leave the code
    David> alone.

This thread is getting a bit long.  Can someone summarize how the expected
usage of the csv module is supposed to change?  If I read things correctly,
instead of requiring (in the general case) that csv files be opened in
binary mode, the requirement will be that they be opened with newline=''.
This will thwart any attempts by the io module at newline translation, but
since the file is still opened in text mode its contents will implicitly be
Unicode (or Unicode translated to bytes with a specific encoding).  That
encoding will also be specified in the call to open().

Is this about correct?  Do any test cases need to be updated or added?  I
notice that something called BytesIO is imported from io but not used.  Were
some test cases removed which used to involve that class or is that a 2to3
artifact?

Skip

----------

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


More information about the Python-bugs-list mailing list