diff options
author | Victor Stinner <vstinner@python.org> | 2020-11-02 15:49:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-02 15:49:54 (GMT) |
commit | 4b9aad49992a825d8c76e428ed1aca81dd3878b2 (patch) | |
tree | 3834f555ab9a469313ba1783b1e2e5ca7af94e51 /Doc/glossary.rst | |
parent | 301822859b3fc34801a06f1090d62f9f2ee5b092 (diff) | |
download | cpython-4b9aad49992a825d8c76e428ed1aca81dd3878b2.zip cpython-4b9aad49992a825d8c76e428ed1aca81dd3878b2.tar.gz cpython-4b9aad49992a825d8c76e428ed1aca81dd3878b2.tar.bz2 |
bpo-42236: Enhance init and encoding documentation (GH-23109)
Enhance the documentation of the Python startup, filesystem encoding
and error handling, locale encoding. Add a new "Python UTF-8 Mode"
section.
* Add "locale encoding" and "filesystem encoding and error handler"
to the glossary
* Remove documentation from Include/cpython/initconfig.h: move it to
Doc/c-api/init_config.rst.
* Doc/c-api/init_config.rst:
* Document command line options and environment variables
* Document default values.
* Add a new "Python UTF-8 Mode" section in Doc/library/os.rst.
* Add warnings to Py_DecodeLocale() and Py_EncodeLocale() docs.
* Document how Python selects the filesystem encoding and error
handler at a single place: PyConfig.filesystem_encoding and
PyConfig.filesystem_errors.
* PyConfig: move orig_argv member at the right place.
Diffstat (limited to 'Doc/glossary.rst')
-rw-r--r-- | Doc/glossary.rst | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Doc/glossary.rst b/Doc/glossary.rst index 4fd01e0..506973e 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -386,6 +386,25 @@ Glossary file-like object A synonym for :term:`file object`. + filesystem encoding and error handler + Encoding and error handler used by Python to decode bytes from the + operating system and encode Unicode to the operating system. + + The filesystem encoding must guarantee to successfully decode all bytes + below 128. If the file system encoding fails to provide this guarantee, + API functions can raise :exc:`UnicodeError`. + + The :func:`sys.getfilesystemencoding` and + :func:`sys.getfilesystemencodeerrors` functions can be used to get the + filesystem encoding and error handler. + + The :term:`filesystem encoding and error handler` are configured at + Python startup by the :c:func:`PyConfig_Read` function: see + :c:member:`~PyConfig.filesystem_encoding` and + :c:member:`~PyConfig.filesystem_errors` members of :c:type:`PyConfig`. + + See also the :term:`locale encoding`. + finder An object that tries to find the :term:`loader` for a module that is being imported. @@ -673,6 +692,18 @@ Glossary thread removes *key* from *mapping* after the test, but before the lookup. This issue can be solved with locks or by using the EAFP approach. + locale encoding + On Unix, it is the encoding of the LC_CTYPE locale. It can be set with + ``locale.setlocale(locale.LC_CTYPE, new_locale)``. + + On Windows, it is is the ANSI code page (ex: ``cp1252``). + + ``locale.getpreferredencoding(False)`` 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. + list A built-in Python :term:`sequence`. Despite its name it is more akin to an array in other languages than to a linked list since access to |