[issue43510] PEP 597: Implemente encoding="locale" option and EncodingWarning

Inada Naoki report at bugs.python.org
Tue Mar 30 08:07:35 EDT 2021


Inada Naoki <songofacandy at gmail.com> added the comment:

In bpo-43651, I found code pattern that it's difficult to use io.text_encoding():

    class OpenWrapper:
        def __new__(cls, *args, **kwargs):
            return open(*args, **kwargs)

`kwargs["encoding"] = text_encoding(kwargs.get("encoding)` doesn't work because `open(filename, "b", encoding="locale")` raises `ValueError: binary mode doesn't take an encoding argument`.

I think we should accept `encoding="locale"` even in binary mode. It makes easy to use `text_encoding()` and `encoding="locale"`.

----------
resolution: fixed -> 
status: closed -> open

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43510>
_______________________________________


More information about the Python-bugs-list mailing list