Georg Brandl ge...@python.org added the comment:
Setting #4847 as superseder.
--
nosy: +georg.brandl
resolution: - duplicate
status: open - closed
superseder: - csv fails when file is opened in binary mode
___
Python tracker rep...@bugs.python.org
Skip Montanaro s...@pobox.com added the comment:
Jervis So the returned lineobj is a bytes type and then the
Jervis PyUnicode_Check throws the error.
Right, but given that fact how do you get a Unicode string out of the bytes
without an encoding? You can't open a file in binary mode and
New submission from Skip Montanaro s...@pobox.com:
I just discovered that the csv module's reader class in 3.x doesn't work
as expected when used as documented. The requirement has always been
that the CSV file is opened in binary mode so that embedded newlines in
fields are screwed up. Alas,
Changes by Jervis Whitley jervi...@gmail.com:
--
nosy: +jdwhitley
nosy_count: 1.0 - 2.0
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5455
___
___
Jervis Whitley jervi...@gmail.com added the comment:
in _csv.c, the check is done here:
lineobj = PyIter_Next(self-input_iter);
if (lineobj == NULL) {
/* End of input OR exception */
if (!PyErr_Occurred() self-field_len != 0)
PyErr_Format(error_obj,
newline
Jervis Whitley jervi...@gmail.com added the comment:
Hi Skip,
Currently, once we are sure the lineobj is a unicode obj we then
get it's internal buffer using:
line = PyUnicode_AsUnicode(lineobj);
for the purpose of iterating through the line.
is there an opportunity to use:
line =
John Machin sjmac...@users.sourceforge.net added the comment:
This is in effect a duplicate of issue 4847.
Summary:
The docs are CORRECT.
The 3.X implementation is WRONG.
The 2.X implementation is CORRECT.
See examples in my comment on issue 4847.
--
message_count: 3.0 - 4.0
nosy: