Skip to content

Commit 3161f01

Browse files
[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 9f25c1f) Co-authored-by: RUANG (James Roy) <[email protected]>
1 parent d71b167 commit 3161f01

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Doc/c-api/unicode.rst

+9
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,15 @@ APIs:
607607
decref'ing the returned objects.
608608
609609
610+
.. c:function:: const char* PyUnicode_GetDefaultEncoding(void)
611+
612+
Return the name of the default string encoding, ``"utf-8"``.
613+
See :func:`sys.getdefaultencoding`.
614+
615+
The returned string does not need to be freed, and is valid
616+
until interpreter shutdown.
617+
618+
610619
.. c:function:: Py_ssize_t PyUnicode_GetLength(PyObject *unicode)
611620
612621
Return the length of the Unicode object, in code points.

Doc/data/refcounts.dat

+3
Original file line numberDiff line numberDiff line change
@@ -2756,6 +2756,9 @@ PyUnicode_FromFormatV:PyObject*::+1:
27562756
PyUnicode_FromFormatV:const char*:format::
27572757
PyUnicode_FromFormatV:va_list:args::
27582758

2759+
PyUnicode_GetDefaultEncoding:const char*:::
2760+
PyUnicode_GetDefaultEncoding::void::
2761+
27592762
PyUnicode_GetLength:Py_ssize_t:::
27602763
PyUnicode_GetLength:PyObject*:unicode:0:
27612764

Doc/library/sys.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,8 @@ always available. Unless explicitly noted otherwise, all variables are read-only
764764

765765
.. function:: getdefaultencoding()
766766

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

770770

771771
.. function:: getdlopenflags()

0 commit comments

Comments
 (0)