Message 389100 - Python tracker (original) (raw)

On 19.03.2021 14:57, Inada Naoki wrote:

Background: PEP 597 adds new encoding="locale"option to open() and TextIOWrapper(). It is same to encoding=None for now, but it means using "locale encoding" explicitly.

But this is wrong in UTF-8 mode.

Please address UTF-8 mode explicitly in open() or elsewhere. The locale module is about the state of the lib C, not what Python enforces via options in its own I/O layers.

As mentioned, both should ideally be synchronized, though, so UTF-8 mode in Python should trigger setting a UTF-8 encoding via setlocale().