Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 62165d6

Browse files
author
Victor Stinner
committed
Document that the 'strict' error handler is used to encode/decode filenames on
Windows
1 parent 257d38f commit 62165d6

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

Doc/c-api/unicode.rst

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,26 +412,33 @@ used, passing :c:func:`PyUnicode_FSDecoder` as the conversion function:
412412
413413
.. c:function:: PyObject* PyUnicode_DecodeFSDefaultAndSize(const char *s, Py_ssize_t size)
414414
415-
Decode a null-terminated string using :c:data:`Py_FileSystemDefaultEncoding`
416-
and the ``"surrogateescape"`` error handler.
415+
Decode a string using :c:data:`Py_FileSystemDefaultEncoding` and the
416+
``'surrogateescape'`` error handler, or ``'strict'`` on Windows.
417417
418418
If :c:data:`Py_FileSystemDefaultEncoding` is not set, fall back to UTF-8.
419419
420-
Use :c:func:`PyUnicode_DecodeFSDefaultAndSize` if you know the string length.
420+
.. versionchanged:: 3.2
421+
Use ``'strict'`` error handler on Windows.
421422
422423
423424
.. c:function:: PyObject* PyUnicode_DecodeFSDefault(const char *s)
424425
425-
Decode a string using :c:data:`Py_FileSystemDefaultEncoding` and
426-
the ``"surrogateescape"`` error handler.
426+
Decode a null-terminated string using :c:data:`Py_FileSystemDefaultEncoding`
427+
and the ``'surrogateescape'`` error handler, or ``'strict'`` on Windows.
427428
428429
If :c:data:`Py_FileSystemDefaultEncoding` is not set, fall back to UTF-8.
429430
431+
Use :c:func:`PyUnicode_DecodeFSDefaultAndSize` if you know the string length.
432+
433+
.. versionchanged:: 3.2
434+
Use ``'strict'`` error handler on Windows.
435+
430436
431437
.. c:function:: PyObject* PyUnicode_EncodeFSDefault(PyObject *unicode)
432438
433439
Encode a Unicode object to :c:data:`Py_FileSystemDefaultEncoding` with the
434-
``'surrogateescape'`` error handler, and return :class:`bytes`.
440+
``'surrogateescape'`` error handler, or ``'strict'`` on Windows, and return
441+
:class:`bytes`.
435442
436443
If :c:data:`Py_FileSystemDefaultEncoding` is not set, fall back to UTF-8.
437444

Doc/library/os.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ process and user.
158158
.. function:: fsencode(filename)
159159

160160
Encode *filename* to the filesystem encoding with ``'surrogateescape'``
161-
error handler, return :class:`bytes` unchanged. On Windows, use ``'strict'``
162-
error handler if the filesystem encoding is ``'mbcs'`` (which is the default
163-
encoding).
161+
error handler, or ``'strict'`` on Windows; return :class:`bytes` unchanged.
164162

165163
:func:`fsdecode` is the reverse function.
166164

@@ -170,9 +168,7 @@ process and user.
170168
.. function:: fsdecode(filename)
171169

172170
Decode *filename* from the filesystem encoding with ``'surrogateescape'``
173-
error handler, return :class:`str` unchanged. On Windows, use ``'strict'``
174-
error handler if the filesystem encoding is ``'mbcs'`` (which is the default
175-
encoding).
171+
error handler, or ``'strict'`` on Windows; return :class:`str` unchanged.
176172

177173
:func:`fsencode` is the reverse function.
178174

0 commit comments

Comments
 (0)