@@ -152,28 +152,29 @@ Operating System Utilities
152152 <c-preinit>` and so that the LC_CTYPE locale is properly configured: see
153153 the :c:func: `Py_PreInitialize ` function.
154154
155- Decode a byte string from the :term: `filesystem encoding and error handler `.
156- If the error handler is :ref: `surrogateescape error handler
157- <surrogateescape>`, undecodable bytes are decoded as characters in range
158- U+DC80..U+DCFF; and if a byte sequence can be decoded as a surrogate
159- character, the bytes are escaped using the surrogateescape error handler
160- instead of decoding them.
155+ Decode a byte string from the :term: `filesystem encoding <filesystem
156+ encoding and error handler> ` with the :ref: `surrogateescape error handler
157+ <surrogateescape>`.
158+
159+ Undecodable bytes are decoded as characters in range U+DC80..U+DCFF. If a
160+ byte sequence can be decoded as a surrogate character, escape the bytes
161+ using the surrogateescape error handler instead of decoding them.
161162
162163 Return a pointer to a newly allocated wide character string, use
163164 :c:func: `PyMem_RawFree ` to free the memory. If size is not ``NULL ``, write
164165 the number of wide characters excluding the null character into ``*size ``
165166
166- Return ``NULL `` on decoding error or memory allocation error. If *size * is
167- not ``NULL ``, ``*size `` is set to ``(size_t)-1 `` on memory error or set to
168- ``(size_t)-2 `` on decoding error.
167+ On memory allocation failure, set *\* size * to ``(size_t)-1 `` and return
168+ ``NULL ``.
169+
170+ On decode error, set *\* size * to ``(size_t)-2 `` and return ``NULL ``.
171+ Decoding errors should never happen, unless there is a bug in the C
172+ library.
169173
170174 The :term: `filesystem encoding and error handler ` are selected by
171175 :c:func: `PyConfig_Read `: see :c:member: `~PyConfig.filesystem_encoding ` and
172176 :c:member: `~PyConfig.filesystem_errors ` members of :c:type: `PyConfig `.
173177
174- Decoding errors should never happen, unless there is a bug in the C
175- library.
176-
177178 Use the :c:func: `Py_EncodeLocale ` function to encode the character string
178179 back to a byte string.
179180
@@ -195,17 +196,19 @@ Operating System Utilities
195196
196197.. c :function :: char * Py_EncodeLocale (const wchar_t *text, size_t *error_pos)
197198
198- Encode a wide character string to the :term: `filesystem encoding and error
199- handler `. If the error handler is :ref: `surrogateescape error handler
200- <surrogateescape>`, surrogate characters in the range U+DC80..U+DCFF are
201- converted to bytes 0x80..0xFF.
199+ Encode a wide character string to the :term: `filesystem encoding <filesystem
200+ encoding and error handler> ` with the :ref: `surrogateescape error handler
201+ <surrogateescape>`. Surrogate characters in the range U+DC80..U+DCFF are
202+ encoded to bytes 0x80..0xFF.
202203
203204 Return a pointer to a newly allocated byte string, use :c:func: `PyMem_Free `
204- to free the memory. Return ``NULL `` on encoding error or memory allocation
205- error.
205+ to free the memory.
206+
207+ On memory allocation failure, set *\* error_pos * to ``(size_t)-1 `` and return
208+ ``NULL ``.
206209
207- If error_pos is not `` NULL ``, `` * error_pos`` is set to `` (size_t)-1 `` on
208- success, or set to the index of the invalid character on encoding error .
210+ On encoding error, set * \* error_pos* to the index of the first unencodable
211+ character and return `` NULL `` .
209212
210213 The :term: `filesystem encoding and error handler ` are selected by
211214 :c:func: `PyConfig_Read `: see :c:member: `~PyConfig.filesystem_encoding ` and
0 commit comments