[Csv] Switch to universal mode?

Andrew McNamara andrewm at object-craft.com.au
Wed Jun 16 04:25:23 CEST 2004


>I've been thinking we should enforce universal mode in the csv module.  I
>think it could simplify the reader a bit (all EOLs become '\n', right?).
>Unfortunately, universal mode is a read-only thing (PEP 278 disallows 'wU'
>though the file object doesn't currently enforce that).  Users would still
>have to open files for writing in binary mode.
>
>Accordingly, I think we should provide a little help for users in the form
>of mode checking and exception raising where possible.  I don't know what
>might be possible for file-like objects (e.g., StringIO) that don't have
>modes.  Does the attached context diff look reasonable?  All it does is
>enforce the relevant modes.  It doesn't attempt to take advantage of the
>'rU' assumption to simplify any code.

I'm not convinced this is necessary or desirable - what will the universal
newline code do to a CR or LF embedded in a quoted field (it's important
to preserve these verbatim)? The resulting simplifications to the parser
are relatively minor, I think.

Certainly the parser needs some tweaking in this area - I just haven't
had time to get back into it. There were also a bunch of issues raised
some time back regarding GC that we should review.

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/


More information about the Csv mailing list