Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,12 @@ APIs:
decref'ing the returned objects.


.. c:function:: const char* PyUnicode_GetDefaultEncoding(void)

Return a ``"utf-8"`` string constant, which corresponds to the
:func:`~sys.getdefaultencoding` function in Python.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest this wording, plus making lifetime explicit since we're returning a buffer.
(Currently the string is static of course, but if it'd ever become dynamic again, it'd need to be borrowed from the interpreter.)

Suggested change
Return a ``"utf-8"`` string constant, which corresponds to the
:func:`~sys.getdefaultencoding` function in Python.
Return the name of the default string encoding, ``"utf-8"``.
See :func:`sys.getdefaultencoding`.
The returned string does not need to be freed, and is valid
until interpreter shutdown.



.. c:function:: Py_ssize_t PyUnicode_GetLength(PyObject *unicode)

Return the length of the Unicode object, in code points.
Expand Down
3 changes: 3 additions & 0 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -2750,6 +2750,9 @@ PyUnicode_FromFormatV:PyObject*::+1:
PyUnicode_FromFormatV:const char*:format::
PyUnicode_FromFormatV:va_list:args::

PyUnicode_GetDefaultEncoding:const char*:::
PyUnicode_GetDefaultEncoding::void::

PyUnicode_GetLength:Py_ssize_t:::
PyUnicode_GetLength:PyObject*:unicode:0:

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,8 @@ always available. Unless explicitly noted otherwise, all variables are read-only

.. function:: getdefaultencoding()

Return the name of the current default string encoding used by the Unicode
implementation.
Return ``'utf-8'``. This is the name of the default string encoding, used
in methods like :meth:`str.encode`.


.. function:: getdlopenflags()
Expand Down
Loading