]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-46236: Add docs for PyUnicode_GetDefaultEncoding() doc (GH-130335) (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 24 Feb 2025 16:10:27 +0000 (17:10 +0100)
committerGitHub <noreply@github.com>
Mon, 24 Feb 2025 16:10:27 +0000 (17:10 +0100)
* 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) <longjinyii@outlook.com>
Doc/c-api/unicode.rst
Doc/data/refcounts.dat
Doc/library/sys.rst

index 3dd3b3a36c2ff54716189b86adbe7b350924e0c1..cce15b700a845c60000c3542163ad3e4d4505516 100644 (file)
@@ -591,6 +591,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.
index fb1215df777644d9516c81d20818c21c0066b42b..cb186b6db3398ba70f8b88b54d76d99b770f3424 100644 (file)
@@ -2755,6 +2755,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:
 
index 2ba70cbf7c6a4496727c04fdaf51fd7c8938f5f1..add1d53153c39df654a2d2dbcff30cf55c67fc4e 100644 (file)
@@ -751,8 +751,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()