summaryrefslogtreecommitdiff
path: root/doc/python3.rst
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2017-05-12 12:23:31 +0200
committerOlivier Dony <odo@openerp.com>2017-08-20 23:25:54 +0200
commitbe7c5aefdf10ad424f2f3c442e135fb81af3d419 (patch)
tree45c7428ee29a5be8e48c72eb2fa1315067120705 /doc/python3.rst
parent0797cfd355df531d801e9d152898ae9046403f2a (diff)
[FIX] P3: CSV reading & writing
Diffstat (limited to 'doc/python3.rst')
-rw-r--r--doc/python3.rst20
1 files changed, 20 insertions, 0 deletions
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/