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

2009-04-03 Thread Benjamin Peterson
Benjamin Peterson benja...@python.org added the comment: So this is a doc bug? If so, need it still block tomorrow's release? -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4847

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

2009-04-03 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Nope. Sorry I forgot to change the priority. -- priority: release blocker - normal ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4847

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

2009-04-03 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: 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?

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

2009-04-03 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Oh, yeah, other 3.1 differences are that the unicode test is uncommented and updated, and a test is added to make sure nulls are handled correctly. -- ___ Python tracker rep...@bugs.python.org

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

2009-04-03 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Doc patch applied in r71116. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4847 ___

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

2009-04-02 Thread Skip Montanaro
Skip Montanaro s...@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

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

2009-04-02 Thread Skip Montanaro
Skip Montanaro s...@pobox.com added the comment: David I also deleted the unicode discussion (since CSV obviously David handles unicode now) ... Maybe there should be a simple example showing use of the encoding parameter to open() to encode Unicode on write and decode to Unicode on read?

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

2009-04-02 Thread R David Murray
R David Murray rdmur...@bitdance.com added the comment: On Thu, 2 Apr 2009 at 17:55, Skip Montanaro wrote: 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

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

2009-04-01 Thread Guido van Rossum
Guido van Rossum gu...@python.org added the comment: I think it's good if it allowed passing in a binary file and an encoding, but I think it would be crazy if it wouldn't also take a text file. After all the primary purpose of a CSV file, edge cases notwithstanding, is to look like text to the

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

2009-04-01 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: I've added some unit tests for embedded newlines, and py3k csv passes (on linux at least) when newline='' is used. Unless someone can provide a test case that fails when newline='' is used, I propose we fix the documentation and leave the

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

2009-04-01 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: I'm attaching a proposed doc patch for comment. I replace mentions of 'rb' with newline='', including in the examples. I also deleted the unicode discussion (since CSV obviously handles unicode now) as well as the extensive unicode

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

2009-04-01 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: Removed file: http://bugs.python.org/file13569/issue4847-doc.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4847 ___

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

2009-04-01 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: -- assignee: georg.brandl - r.david.murray Added file: http://bugs.python.org/file13570/issue4847-doc.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4847

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

2009-03-10 Thread Skip Montanaro
Skip Montanaro s...@pobox.com added the comment: This issue seems to have simply been overlooked when 3.0 was released. It should be fixed in the next round of 3.0 and 3.1 updates. Any feeback on the idea that the csv.reader constructor (and probably the DictReader and proposed NamedTupleReader

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

2009-03-09 Thread John Machin
John Machin sjmac...@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

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

2009-03-09 Thread John Machin
John Machin sjmac...@users.sourceforge.net added the comment: ... and it looks like Option 2 might already *almost* be in place. Continuing with the previous example (book1.csv has embedded lone LFs): C:\devel\csv\python30\python -c import csv; print(repr(list(csv.reader(open('book1.csv','rt',

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

2009-03-09 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Not good. It should preserve ALL characters in the field. Please look at the doc for open() and io.TextIOWrapper. The `newline` parameter defaults to None, which means universal newlines with newline translation. Setting to '' (yes, the empty

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

2009-03-09 Thread John Machin
John Machin sjmac...@users.sourceforge.net added the comment: pitrou Please look at the doc for open() and io.TextIOWrapper. The `newline` parameter defaults to None, which means universal newlines with newline translation. Setting to '' (yes, the empty string) enables universal newlines but

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

2009-03-09 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: I had already read it. I gave it a prize for least intuitive arg in the language. Please open a bug, then :) So you plan to use that, reading lines instead of blocks? You'll still have to examine which CRs and LFs are embedded and which are

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

2009-03-09 Thread Skip Montanaro
Skip Montanaro s...@pobox.com added the comment: me What should be the default? Scratch that. If the iterator passed to csv.reader is in a mode which will cause it to emit bytes instead of unicode objects the caller must give an encoding. The csv.reader code will then perform the necessary

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

2009-03-08 Thread Jervis Whitley
Jervis Whitley jervi...@gmail.com added the comment: Hi all, This patch takes the approach of assuming utf-8 format encoding for files opened with 'rb' directive. That is: 1. Check if each line is Unicode Or Bytes Type. 2. If Bytes, get char array reference to internal buffer. 3. use

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

2009-02-23 Thread John Machin
John Machin sjmac...@users.sourceforge.net added the comment: Sorry, folks, we've got an understanding problem here. CSV files are typically NOT created by text editors. They are created e.g. by save as csv from a spreadsheet program, or as an output option by some database query program. They

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

2009-01-05 Thread jaywalker
: [issue4847] csv fails when file is opened in binary mode STINNER Victor victor.stin...@haypocalc.com added the comment: Do you expect to be able to read CSV as bytes or just to fix the documentation example? -- nosy: +haypo ___ Python tracker rep

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

2009-01-05 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: say one of the fields has an embedded \r. For instance blahblah\r is the value of the first column. Now open this file in text mode. What happens to this '\r' even before csv.reader sees it? I used rarely the CSV format, but it

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

2009-01-05 Thread jaywalker
be wrong). Thus, \r gets lost. Not a biggie, but you never know ;0) - Original Message From: STINNER Victor rep...@bugs.python.org To: jaywal...@yahoo.com Sent: Monday, January 5, 2009 12:23:45 PM Subject: [issue4847] csv fails when file is opened in binary mode STINNER Victor victor.stin

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

2009-01-05 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: You can avoid the newline translation problem by using the newline parameter in open(). Set it to '' (the empty string) and any CR and LF characters should remain intact. As for the original problem, IMHO it is a documentation bug. --

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

2009-01-05 Thread jaywalker
jaywalker jaywal...@yahoo.com added the comment: I think what you suggest makes most sense. Thanks. - Original Message From: Antoine Pitrou rep...@bugs.python.org To: jaywal...@yahoo.com Sent: Monday, January 5, 2009 12:47:21 PM Subject: [issue4847] csv fails when file is opened

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

2009-01-05 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Do you expect to be able to read CSV as bytes or just to fix the documentation example? -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4847

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

2009-01-05 Thread jaywalker
New submission from jaywalker jaywal...@yahoo.com: The following code from the documentation fails: # import csv reader = csv.reader(open(eggs.csv, rb)) for row in reader: print(row) # The output is: Traceback (most recent call last): File stdin, line 1,

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

2009-01-05 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com added the comment: Short patch fixing the examples + the description of reader() and writer() (remove the b flag sentence: it's wrong, we need unicode!). I hope that I didn't break the documentation (i tried make text and i didn't get any warning).