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

Jervis Whitley report at bugs.python.org
Mon Mar 9 06:11:32 CET 2009


Jervis Whitley <jervisau at 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 PyUnicode_FromString to create a new unicode object from the
char* - This step assumes UTF-8.
4. get a Py_UNICODE reference to internal unicode object buffer and 
   continue as before.

Is this in the right direction at all?

Cheers,

Jervis

----------
message_count: 9.0 -> 10.0
nosy: +jdwhitley
nosy_count: 5.0 -> 6.0
Added file: http://bugs.python.org/file13279/csv.diff

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


More information about the Python-bugs-list mailing list