]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-46236: Add docs for PyUnicode_GetDefaultEncoding() doc (GH-130335)
authorRUANG (James Roy) <longjinyii@outlook.com>
Mon, 24 Feb 2025 14:37:21 +0000 (22:37 +0800)
committerGitHub <noreply@github.com>
Mon, 24 Feb 2025 14:37:21 +0000 (15:37 +0100)
* Clarify sys.getdefaultencoding() documentation

* Add missing documentation for PyUnicode_GetDefaultEncoding,
  the C equivalent of sys.getdefaultencoding

Doc/c-api/unicode.rst
Doc/data/refcounts.dat
Doc/library/sys.rst

index e79aa94036e2073808b7dccee2f72b3183006a3b..0b1c1f626b5ca79295adaa46596d828c520ee9df 100644 (file)
@@ -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.
index 7f576d21ff489d45e7245ad60eee6512497f880a..15591fbefcd588132b89bafe7adf82725ee676e6 100644 (file)
@@ -2770,6 +2770,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 67dc3e7f2982d724f29d05873fe4801e277dec0e..2bdfb337f02056b25bb0c91ea2ff8491f84d2af0 100644 (file)
@@ -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()