IMO adding locale.getencoding() to Python 3.11 is not controversial
and is useful even if PEP 686 is rejected. This function was discussed
for 1 year (bpo-43510, bpo-43552, bpo-43557, bpo-47000) and there is
an agreement that there is a need for this function.

> Making `open(path, encoding="locale")` use locale encoding in UTF-8 mode 
> (Python 3.10 used UTF-8)

If someone explicitly opts in for the "locale encoding", it sounds
surprising that the locale (encoding) is ignored and that UTF-8 is
used if the Python UTF-8 Mode is enabled. I'm fine with this change.
If you want to always UTF-8... Pass explicitly UTF-8:

    # no surprise, always decode file content from UTF-8
    json_file = open(filename, encoding="utf-8")

--

I will not comment PEP 686 here. It's being discussed on Discourse:

* https://discuss.python.org/t/14435
* https://discuss.python.org/t/14737

Victor

On Thu, Apr 7, 2022 at 5:35 AM Inada Naoki <songofaca...@gmail.com> wrote:
>
> Hi, Pablo.
>
> I just submitted the PEP 686 to the SC.
> https://github.com/python/steering-council/issues/118
>
> In this PEP, I am proposing:
>
> a. Small improvement for UTF-8 mode in Python 3.11
> b. Make UTF-8 mode default in Python 3.13.
>
> (a) is an important change for (b) so I included it in the PEP.
> More precisely, (a) contains two changes:
>
> * Making `open(path, encoding="locale")` use locale encoding in UTF-8
> mode (Python 3.10 used UTF-8)
> * Add `locale.getencoding()` that is same to
> `locale.getpreferredencoding(False)` but returns locale encoding even
> in UTF-8 mode.
>
> These changes are important for (b).
> But they are not a big change needing PEP.
>
> What should I do?
>
> * Do not merge anything until PEP accepted.
> * Merge (a) without waiting PEP accepted.
> * Merge (a) and remove it from the PEP.
>
> FWI, I and Victor are implementing `locale.getencoding()` for now.
>
> https://bugs.python.org/issue47000
> https://github.com/python/cpython/pull/32068
>
> Regards,
> --
> Inada Naoki  <songofaca...@gmail.com>
> _______________________________________________
> python-committers mailing list -- python-committers@python.org
> To unsubscribe send an email to python-committers-le...@python.org
> https://mail.python.org/mailman3/lists/python-committers.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-committers@python.org/message/7E4QEKZ6HNDDPDL76LP3TBBKLAUQ7AHB/
> Code of Conduct: https://www.python.org/psf/codeofconduct/



-- 
Night gathers, and now my watch begins. It shall not end until my death.
_______________________________________________
python-committers mailing list -- python-committers@python.org
To unsubscribe send an email to python-committers-le...@python.org
https://mail.python.org/mailman3/lists/python-committers.python.org/
Message archived at 
https://mail.python.org/archives/list/python-committers@python.org/message/KEW2G2O57CNO66QFZ2I3E3D6ILQ67RII/
Code of Conduct: https://www.python.org/psf/codeofconduct/

Reply via email to