[New-bugs-announce] [issue10954] No warning for csv.writer API change
report at bugs.python.org
Thu Jan 20 11:32:28 CET 2011
New submission from Lennart Regebro <regebro at gmail.com>:
In Python 2 the file used for csv.writer() should be opened in binary mode, while in Python 3 is should be opened in text mode but with newlines set to ''.
This change is neither warned for by python -3, nor is there a fixer for it (and making a fixer would be tricky), thus it provides a surprising API change.
I think that csv.writer() should warn or even fail if the file is opened in binary mode under Python 3. Failing is a god option, as a binary file is likely to be a port from Python 2, and you are likely to get the less useful message "must be bytes or buffer, not str". Even if you understand that message, you will then probably just change the file mode from binary to text, but you will not add the lineendings='' parameter, and thusly you might cause subtle error on windows.
components: 2to3 (2.x to 3.0 conversion tool), Library (Lib)
title: No warning for csv.writer API change
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce