https://github.com/python/cpython/commit/3161f01760a85bf093a7d5c154a765dd556b036c commit: 3161f01760a85bf093a7d5c154a765dd556b036c branch: 3.13 author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com> committer: encukou <encu...@gmail.com> date: 2025-02-24T17:10:17+01:00 summary:
[3.13] gh-46236: Add docs for PyUnicode_GetDefaultEncoding() doc (GH-130335) (GH-130511) * Clarify sys.getdefaultencoding() documentation * Add missing documentation for PyUnicode_GetDefaultEncoding, the C equivalent of sys.getdefaultencoding (cherry picked from commit 9f25c1f012c8d432a93bf2dcad5f19a64dc00d3c) Co-authored-by: RUANG (James Roy) <longjin...@outlook.com> files: M Doc/c-api/unicode.rst M Doc/data/refcounts.dat M Doc/library/sys.rst diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index d8652f7981d1ea..a62a4e93a3d13d 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -607,6 +607,15 @@ APIs: decref'ing the returned objects. +.. c:function:: const char* PyUnicode_GetDefaultEncoding(void) + + 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. diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index 448275fdb0aae7..987aa2d60dac8c 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -2756,6 +2756,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: diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 7eb1563e9a3582..68301b74d2f8b0 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -764,8 +764,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() _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com