On Tue, Feb 2, 2021 at 1:40 PM Inada Naoki <songofaca...@gmail.com> wrote: > > On Tue, Feb 2, 2021 at 12:23 AM Victor Stinner <vstin...@python.org> wrote: > > > > > > > Add ``io.LOCALE_ENCODING = "locale"`` constant too. This constant can > > > be used to avoid confusing ``LookupError: unknown encoding: locale`` > > > error when the code is run in old Python accidentally. > > > > I'm not sure that it is useful. I like a simple "locale" literal > > string. If there is a constant is io, people may start to think that > > it's specific and will add "import io" just to get the string > > "locale". > > > > I don't think that we should care too much about the error message > > rased by old Python versions. > > > > This constant not only for replacing "locale" litera. As example code > in the PEP, it can be used to test wheather TextIOWrapper supports > `encoding="locale"` . > > `open(fn, encoding=getattr(io, "LOCALE_ENCODING", None))` works both > for Python ~3.9 and Python 3.10~. >
I changed my mind. Since there is no plan to change the default encoding for now, no need to encourage `encoding="locale"` soon. Until users can drop Python 3.9 support, they can use EncodingWarning only for finding missing `encoding="utf-8"` or `encoding="ascii"`. I will remove the io.LOCALE_ENCODING. -- Inada Naoki <songofaca...@gmail.com> _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/4SRSQQXRLQSXG4RLZGXHFEFTTBVDKPWK/ Code of Conduct: http://python.org/psf/codeofconduct/