Victor Stinner [mailto:firstname.lastname@example.org] wrote:
> The warning can explicitly suggest to use encoding="utf8", it should work in almost all cases.
The warning should also explain how to get backwards-compatible behaviour, i.e. suggest encoding="locale".
Inada Naoki <songofacandy(a)gmail.com> wrote:
> This warning is opt-in warning like BytesWarning.
What use is a warning that no-one sees? When the default is switched to encoding="utf8", it will break software, and people need to be warned of that.
UnicodeDecodeError's will abound when files that used to be read in a single-byte encoding fails to decode as utf-8. All it takes is a single é.
If the default encoding is ever to change, there's no way around a noisy warning.
How about swapping around "locale" and None? That is, make "locale" the new default that emits a warning, and encoding=None emits no warning. That has the advantage that old code can be updated to say encoding=None, and then it will work on both old and new Pythons without warning.