FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-47000: Add `locale.getencoding()` by methane · Pull Request #32068 · python/cpython · GitHub

/ cpython Public

bpo-47000: Add locale.getencoding() - #32068

Merged
methane merged 13 commits into
python:mainfrom
methane:locale-get-encoding
Apr 9, 2022
Merged

bpo-47000: Add locale.getencoding()#32068
methane merged 13 commits into
python:mainfrom
methane:locale-get-encoding

Conversation

methane commented Mar 23, 2022
edited
Loading

Copy link
Copy Markdown
Member

methane force-pushed the locale-get-encoding branch from 04fd5b0 to 8b50eb1 Compare April 4, 2022 03:16
methane changed the title bpo-47000: Add locale.get_encoding() bpo-47000: Add locale.getencoding() Apr 4, 2022
methane changed the title bpo-47000: Add locale.getencoding() bpo-47000: Add locale.getencoding() Apr 4, 2022
methane force-pushed the locale-get-encoding branch from ffc9ba1 to a0204c2 Compare April 4, 2022 04:58
methane requested a review from vstinner April 6, 2022 03:27
Comment thread Doc/library/locale.rst Outdated

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

In some places, "utf-8" is used, in some other places "UTF-8" is used. I suggest to use lower case "utf-8" everywhere: doc, C code, _Py_STR(), etc. You may have to update getpreferredencoding() doc.

Comment thread Doc/glossary.rst
Comment thread Doc/glossary.rst Outdated
Comment thread Doc/glossary.rst
Comment thread Doc/glossary.rst Outdated
Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/whatsnew/3.11.rst Outdated
Comment thread Lib/locale.py Outdated
Comment thread Modules/_io/textio.c Outdated
methane and others added 2 commits April 7, 2022 12:39
Co-authored-by: Victor Stinner <vstinner@python.org>
methane force-pushed the locale-get-encoding branch from 39e99bc to 7720b10 Compare April 7, 2022 04:18
Comment thread Doc/library/locale.rst Outdated

.. versionchanged:: 3.7
The function now always returns ``UTF-8`` on Android or if the
The function now always returns ``"UTF-8"`` on Android or if the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
The function now always returns ``"UTF-8"`` on Android or if the
The function now always returns ``"utf-8"`` on Android or if the

Comment thread Doc/library/locale.rst Outdated

.. versionchanged:: 3.11
The function now returns ``"utf-8"`` instead of ``"UTF-8"`` on Android
or if the :ref:`Python UTF-8 Mode <utf8-mode>` is enabled.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I am sure that the upper case versus lower case is worth to be mentioned. But I'm fine with keeping if you consider that it's worth it.

Comment thread Doc/library/locale.rst
argument are ignored.

The :ref:`Python preinitialization <c-preinit>` configures the LC_CTYPE
locale. See also the :term:`filesystem encoding and error handler`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I suggest to copy/paste this paragraph to getencoding() doc.

Comment thread Doc/whatsnew/3.11.rst Outdated
------

* Add :func:`locale.getencoding` to get the current locale encoding. It is similar to
``locale.getpreferredencoding(False)`` but ignores :ref:`UTF-8 Mode <utf8-mode>`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I like repeating "Python" to remind that it's unrelated to the Unix locale, but really something specific to Python which ignores the locale.

Suggested change
``locale.getpreferredencoding(False)`` but ignores :ref:`UTF-8 Mode <utf8-mode>`.
``locale.getpreferredencoding(False)`` but ignores the :ref:`Python UTF-8 Mode <utf8-mode>`.

@@ -0,0 +1 @@
Add :func:`locale.getencoding`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You can copy/paste the Doc/whatsnew/3.11.rst entry entry.

Comment thread Doc/glossary.rst Outdated
``locale.getencoding()`` can be used to get the locale encoding.

Python uses the :term:`filesystem encoding and error handler` to convert
between Unicode filenames and bytes filenames.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

IMO it would be helpful to mention here the Python UTF-8 Mode which ignores the locale encoding and always uses UTF-8. What do you think?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't think so. This paragraph doesn't describe where the locale encoding is used.
This paragraph describes what the locale encoding is.
With this pull request, locale encoding is locale encoding even in UTF-8 mode.

On the other hand, following this paragraph looks unnecessary:

      Python uses the :term:`filesystem encoding and error handler` to convert
      between Unicode filenames and bytes filenames.

I will replace it with See also :term:`filesystem encoding and error handler`.

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM. Thanks.

IMO it's important that the current is complete and explains well this function, since it's a complex topic. If the doc is unclear, people will misuse it.

Thanks for adding "See also the filesystem encoding and error handler" in the glossary, that's good!

I'm not sure why the PR is still a draft.

methane marked this pull request as ready for review April 9, 2022 00:54
methane merged commit 6773203 into python:main Apr 9, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL