summaryrefslogtreecommitdiff
path: root/Doc/c-api/unicode.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/c-api/unicode.rst')
-rw-r--r--Doc/c-api/unicode.rst53
1 files changed, 29 insertions, 24 deletions
diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst
index 256fef3b27..02f7ada7be 100644
--- a/Doc/c-api/unicode.rst
+++ b/Doc/c-api/unicode.rst
@@ -440,7 +440,6 @@ APIs:
.. % because not all compilers support the %z width modifier -- we fake it
.. % when necessary via interpolating PY_FORMAT_SIZE_T.
.. % Similar comments apply to the %ll width modifier and
- .. % PY_FORMAT_LONG_LONG.
.. tabularcolumns:: |l|l|L|
@@ -525,11 +524,6 @@ APIs:
copied as-is to the result string, and any extra arguments discarded.
.. note::
-
- The `"%lld"` and `"%llu"` format specifiers are only available
- when :const:`HAVE_LONG_LONG` is defined.
-
- .. note::
The width formatter unit is number of characters rather than bytes.
The precision formatter unit is number of bytes for ``"%s"`` and
``"%V"`` (if the ``PyObject*`` argument is NULL), and a number of
@@ -811,38 +805,47 @@ File System Encoding
""""""""""""""""""""
To encode and decode file names and other environment strings,
-:c:data:`Py_FileSystemEncoding` should be used as the encoding, and
-``"surrogateescape"`` should be used as the error handler (:pep:`383`). To
-encode file names during argument parsing, the ``"O&"`` converter should be
-used, passing :c:func:`PyUnicode_FSConverter` as the conversion function:
+:c:data:`Py_FileSystemDefaultEncoding` should be used as the encoding, and
+:c:data:`Py_FileSystemDefaultEncodeErrors` should be used as the error handler
+(:pep:`383` and :pep:`529`). To encode file names to :class:`bytes` during
+argument parsing, the ``"O&"`` converter should be used, passing
+:c:func:`PyUnicode_FSConverter` as the conversion function:
.. c:function:: int PyUnicode_FSConverter(PyObject* obj, void* result)
- ParseTuple converter: encode :class:`str` objects to :class:`bytes` using
+ ParseTuple converter: encode :class:`str` objects -- obtained directly or
+ through the :class:`os.PathLike` interface -- to :class:`bytes` using
:c:func:`PyUnicode_EncodeFSDefault`; :class:`bytes` objects are output as-is.
*result* must be a :c:type:`PyBytesObject*` which must be released when it is
no longer used.
.. versionadded:: 3.1
+ .. versionchanged:: 3.6
+ Accepts a :term:`path-like object`.
-To decode file names during argument parsing, the ``"O&"`` converter should be
-used, passing :c:func:`PyUnicode_FSDecoder` as the conversion function:
+To decode file names to :class:`str` during argument parsing, the ``"O&"``
+converter should be used, passing :c:func:`PyUnicode_FSDecoder` as the
+conversion function:
.. c:function:: int PyUnicode_FSDecoder(PyObject* obj, void* result)
- ParseTuple converter: decode :class:`bytes` objects to :class:`str` using
- :c:func:`PyUnicode_DecodeFSDefaultAndSize`; :class:`str` objects are output
- as-is. *result* must be a :c:type:`PyUnicodeObject*` which must be released
- when it is no longer used.
+ ParseTuple converter: decode :class:`bytes` objects -- obtained either
+ directly or indirectly through the :class:`os.PathLike` interface -- to
+ :class:`str` using :c:func:`PyUnicode_DecodeFSDefaultAndSize`; :class:`str`
+ objects are output as-is. *result* must be a :c:type:`PyUnicodeObject*` which
+ must be released when it is no longer used.
.. versionadded:: 3.2
+ .. versionchanged:: 3.6
+ Accepts a :term:`path-like object`.
+
.. c:function:: PyObject* PyUnicode_DecodeFSDefaultAndSize(const char *s, Py_ssize_t size)
Decode a string using :c:data:`Py_FileSystemDefaultEncoding` and the
- ``"surrogateescape"`` error handler, or ``"strict"`` on Windows.
+ :c:data:`Py_FileSystemDefaultEncodeErrors` error handler.
If :c:data:`Py_FileSystemDefaultEncoding` is not set, fall back to the
locale encoding.
@@ -856,28 +859,28 @@ used, passing :c:func:`PyUnicode_FSDecoder` as the conversion function:
The :c:func:`Py_DecodeLocale` function.
- .. versionchanged:: 3.2
- Use ``"strict"`` error handler on Windows.
+ .. versionchanged:: 3.6
+ Use :c:data:`Py_FileSystemDefaultEncodeErrors` error handler.
.. c:function:: PyObject* PyUnicode_DecodeFSDefault(const char *s)
Decode a null-terminated string using :c:data:`Py_FileSystemDefaultEncoding`
- and the ``"surrogateescape"`` error handler, or ``"strict"`` on Windows.
+ and the :c:data:`Py_FileSystemDefaultEncodeErrors` error handler.
If :c:data:`Py_FileSystemDefaultEncoding` is not set, fall back to the
locale encoding.
Use :c:func:`PyUnicode_DecodeFSDefaultAndSize` if you know the string length.
- .. versionchanged:: 3.2
- Use ``"strict"`` error handler on Windows.
+ .. versionchanged:: 3.6
+ Use :c:data:`Py_FileSystemDefaultEncodeErrors` error handler.
.. c:function:: PyObject* PyUnicode_EncodeFSDefault(PyObject *unicode)
Encode a Unicode object to :c:data:`Py_FileSystemDefaultEncoding` with the
- ``"surrogateescape"`` error handler, or ``"strict"`` on Windows, and return
+ :c:data:`Py_FileSystemDefaultEncodeErrors` error handler, and return
:class:`bytes`. Note that the resulting :class:`bytes` object may contain
null bytes.
@@ -894,6 +897,8 @@ used, passing :c:func:`PyUnicode_FSDecoder` as the conversion function:
.. versionadded:: 3.2
+ .. versionchanged:: 3.6
+ Use :c:data:`Py_FileSystemDefaultEncodeErrors` error handler.
wchar_t Support
"""""""""""""""