From be7c5aefdf10ad424f2f3c442e135fb81af3d419 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 12 May 2017 12:23:31 +0200 Subject: [FIX] P3: CSV reading & writing --- doc/python3.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'doc/python3.rst') diff --git a/doc/python3.rst b/doc/python3.rst index a7d143b85b7..7ca86708ced 100644 --- a/doc/python3.rst +++ b/doc/python3.rst @@ -452,6 +452,26 @@ conversions: text is *encoded* to bytes and bytes are *decoded* to text. migrated to using ``base64.b64encode`` and ``base64.b64decode`` respectively. +csv +--- + +``csv`` is a fairly vicious one: not only is it not a very good format, the +Python 2 and Python 3 versions of the library are text-model incompatible in +significant ways: + +* Python 2's CSV only works on *ascii-compatible byte streams* (it has no + encoding support at all) and extracts bytestring values +* Python 3's CSV only works on *text streams* and extract text values +* And ``io`` doesn't provide "native string" streaming facilities. + +However with respect to Odoo it turns out most or all uses of ``csv`` fit +inside a model of *byte stream to and from text values*. + +The latter is thus a model implemented by cross-version wrappers +:func:`odoo.tools.pycompat.csv_reader` and +:func:`odoo.tools.pycompat.csv_writer`: they take a *UTF-8 byte stream* and +read or write *text* values. + .. _hash randomisation: http://bugs.python.org/issue13703 .. _requests: http://docs.python-requests.org/ -- cgit v1.2.3