From 67ad6f7a29fbbf17c968c31a65ffa34a9e23ad6e Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Thu, 1 May 2025 17:45:36 +0100 Subject: [PATCH 1/2] Document last one! --- Doc/c-api/unicode.rst | 11 +++++++++++ Doc/data/refcounts.dat | 3 +++ 2 files changed, 14 insertions(+) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 95987e872ce639..7dbbd956e080be 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -645,6 +645,17 @@ APIs: difference being that it decrements the reference count of *right* by one. +.. c:function:: PyObject* PyUnicode_BuildEncodingMap(PyObject* string) + + Return a mapping suitable for decoding a custom single-byte encoding. + Given a Unicode string *string* of up to 256 characters representing an encoding + table, returns either a compact internal mapping object or a dictionary + mapping character ordinals to byte values. Raises a :exc:`TypeError` on + invalid input. + + .. versionadded:: 3.2 + + .. c:function:: const char* PyUnicode_GetDefaultEncoding(void) Return the name of the default string encoding, ``"utf-8"``. diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index ca99b9e6d37141..c97cd2b8d1e3cb 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -2781,6 +2781,9 @@ PyUnicode_AppendAndDel:void::: PyUnicode_AppendAndDel:PyObject**:p_left:0: PyUnicode_AppendAndDel:PyObject*:right:-1: +PyUnicode_BuildEncodingMap:PyObject*::+1: +PyUnicode_BuildEncodingMap:PyObject*:string::: + PyUnicode_GetDefaultEncoding:const char*::: PyUnicode_GetDefaultEncoding::void:: From 000ad3f4d76149a2f8053c8976b46fd4291394ab Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Fri, 2 May 2025 15:26:29 +0100 Subject: [PATCH 2/2] Update Doc/c-api/unicode.rst Co-authored-by: Victor Stinner --- Doc/c-api/unicode.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 7dbbd956e080be..cdd90d05b70b36 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -650,8 +650,8 @@ APIs: Return a mapping suitable for decoding a custom single-byte encoding. Given a Unicode string *string* of up to 256 characters representing an encoding table, returns either a compact internal mapping object or a dictionary - mapping character ordinals to byte values. Raises a :exc:`TypeError` on - invalid input. + mapping character ordinals to byte values. Raises a :exc:`TypeError` and + return ``NULL`` on invalid input. .. versionadded:: 3.2