Skip to content

Commit 4b9aad4

Browse files
authored
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.
1 parent 3018228 commit 4b9aad4

19 files changed

+738
-523
lines changed

Doc/c-api/exceptions.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ For convenience, some of these functions will always return a
182182
.. c:function:: PyObject* PyErr_SetFromErrnoWithFilename(PyObject *type, const char *filename)
183183
184184
Similar to :c:func:`PyErr_SetFromErrnoWithFilenameObject`, but the filename
185-
is given as a C string. *filename* is decoded from the filesystem encoding
186-
(:func:`os.fsdecode`).
185+
is given as a C string. *filename* is decoded from the :term:`filesystem
186+
encoding and error handler`.
187187
188188
189189
.. c:function:: PyObject* PyErr_SetFromWindowsErr(int ierr)
@@ -266,7 +266,7 @@ For convenience, some of these functions will always return a
266266
.. c:function:: void PyErr_SyntaxLocationEx(const char *filename, int lineno, int col_offset)
267267
268268
Like :c:func:`PyErr_SyntaxLocationObject`, but *filename* is a byte string
269-
decoded from the filesystem encoding (:func:`os.fsdecode`).
269+
decoded from the :term:`filesystem encoding and error handler`.
270270
271271
.. versionadded:: 3.2
272272
@@ -343,7 +343,7 @@ an error value).
343343
344344
Similar to :c:func:`PyErr_WarnExplicitObject` except that *message* and
345345
*module* are UTF-8 encoded strings, and *filename* is decoded from the
346-
filesystem encoding (:func:`os.fsdecode`).
346+
:term:`filesystem encoding and error handler`.
347347
348348
349349
.. c:function:: int PyErr_WarnFormat(PyObject *category, Py_ssize_t stack_level, const char *format, ...)

Doc/c-api/init.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ to 1 and ``-bb`` sets :c:data:`Py_BytesWarningFlag` to 2.
151151

152152
.. c:var:: int Py_LegacyWindowsFSEncodingFlag
153153
154-
If the flag is non-zero, use the ``mbcs`` encoding instead of the UTF-8
155-
encoding for the filesystem encoding.
154+
If the flag is non-zero, use the ``mbcs`` encoding with ``replace`` error
155+
handler, instead of the UTF-8 encoding with ``surrogatepass`` error handler,
156+
for the :term:`filesystem encoding and error handler`.
156157

157158
Set to ``1`` if the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment
158159
variable is set to a non-empty string.

0 commit comments

Comments
 (0)