[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-04-03 Thread Inada Naoki
Inada Naoki added the comment: New changeset 4216dce04b7d3f329beaaafc82a77c4ac6cf4d57 by Inada Naoki in branch 'main': bpo-47000: Make `io.text_encoding()` respects UTF-8 mode (GH-32003) https://github.com/python/cpython/commit/4216dce04b7d3f329beaaafc82a77c4ac6cf4d57 --

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-30 Thread Inada Naoki
Inada Naoki added the comment: > Please see https://bugs.python.org/issue47000#msg415769 for what Victor > suggested. Of course, I read it. > In particular, the locale module uses the "no underscore" convention. > Not sure whether it's good to start using snake case now, but I'm also > not

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-30 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Please see https://bugs.python.org/issue47000#msg415769 for what Victor suggested. In particular, the locale module uses the "no underscore" convention. Not sure whether it's good to start using snake case now, but I'm also not against it. I would like

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-30 Thread Inada Naoki
Inada Naoki added the comment: @vstiner Since UTF-8 mode affects `locale.getpreferredencoding(False)`, I need to decide alternative API in the PEP 686. If no objections, I will choose `locale.get_encoding()` for current locale encoding (ACP on Windows). See

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-23 Thread Inada Naoki
Inada Naoki added the comment: I am not sure about we really need "locale encoding at Python startup". For this issue, I don't want to change `encoding="locale"` behavior except ignore UTF-8 mode. So what I want is "current locale encoding" or ANSI codepage on Windows. On the other hand,

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-23 Thread STINNER Victor
STINNER Victor added the comment: sys.getlocaleencoding() versus locale.getencoding(). For me, the Python locale module should use the C API to access the Unix locales like LC_CTYPE, nl_langinfo(CODESET), etc. The sys module are more for things specific to Python, like

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-22 Thread Inada Naoki
Change by Inada Naoki : -- pull_requests: +30157 pull_request: https://github.com/python/cpython/pull/32068 ___ Python tracker ___

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-22 Thread Inada Naoki
Inada Naoki added the comment: > * sys.getfilesystemencoding(): Python filesystem encoding, return "UTF-8" if > the Python UTF-8 Mode is enabled Yes, althoguh PYTHONLEGACYWINDOWSFSENCODING takes priority. > * locale.getencoding(): Get the locale encoding, LC_CTYPE locale encoding or > the

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-22 Thread STINNER Victor
STINNER Victor added the comment: I propose: * sys.getfilesystemencoding(): Python filesystem encoding, return "UTF-8" if the Python UTF-8 Mode is enabled * Implementation: PyConfig.filesystem_encoding * https://docs.python.org/dev/library/sys.html#sys.getfilesystemencoding *

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-22 Thread STINNER Victor
STINNER Victor added the comment: > But some user want to use UTF-8 mode to change default encoding in their > Python environments without waiting Python default encoding changed. IMO it's a different use case and it should be a different thing. Changing encoding="locale" today is too late,

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-22 Thread STINNER Victor
STINNER Victor added the comment: > Is it safe to use `locale.getlocale(locale.LC_CTYPE)[1] or "UTF-8"`? I would like to deprecate getlocale(), see bpo-43557. -- ___ Python tracker

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-19 Thread Inada Naoki
Change by Inada Naoki : -- keywords: +patch pull_requests: +30091 stage: -> patch review pull_request: https://github.com/python/cpython/pull/32003 ___ Python tracker ___

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-15 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: FWIW: I don't think the "locale" encoding is a good idea. Instead of trying to fix this to make it more usable, I'd suggest to deprecate and remove it again. When it comes to encodings, explicit is better than implicit. If an application wants to work

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-15 Thread Inada Naoki
Inada Naoki added the comment: I created another topic relating this issue. https://discuss.python.org/t/add-legacy-text-encoding-option-to-make-utf-8-default/14281 If we add another option (e.g. legacy_text_encoding), we do not need to change UTF-8 mode behavior. --

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-14 Thread STINNER Victor
STINNER Victor added the comment: There are multiple "locale encodings": * "current" locale encoding: locale.nl_langinfo(locale.CODESET) * "Python" locale encoding: locale.getpreferredencoding(False), ignore the locale in UTF-8 Mode (always return "UTF-8"), ignore the locale on Android and

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-14 Thread STINNER Victor
STINNER Victor added the comment: > So I think `encoding="locale"` should use real locale encoding (ACP on > Windows) regardless UTF-8 mode is enabled or not. If you want to change the default, would it be possible to add a function to get this encoding? --

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-13 Thread Inada Naoki
Inada Naoki added the comment: I created a related topic on discuss.python.org. https://discuss.python.org/t/jep-400-utf-8-by-default-and-future-of-python/14246 If we recommend `PYTHONUTF8` as opt-in "UTF-8 by default", `encoding="locale"` should locale encoding in UTF-8 mode. If we don't

[issue47000] Make encoding="locale" uses locale encoding even in UTF-8 mode is enabled.

2022-03-12 Thread Inada Naoki
New submission from Inada Naoki : Currently, `encoding="locale"` is just shortcut of `encoding=locale.getpreferredencoding(False)`. `encoding="locale"` means that "locale encoding should be used here, even if Python default encoding is changed to UTF-8". I am not sure that UTF-8 mode