From c824a20c534b839bb4ff7a3e2551a05d49897864 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 18 Dec 2020 14:22:34 -0700 Subject: [PATCH] bpo-39560: Document PyUnicode_FromKindAndData() kind transformation --- Doc/c-api/unicode.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index b7f99d32558b89f..70896eed5975dbb 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -422,6 +422,12 @@ APIs: :c:func:`PyUnicode_KIND`). The *buffer* must point to an array of *size* units of 1, 2 or 4 bytes per character, as given by the kind. + If necessary, the input *buffer* is copied and transformed into the + canonical representation. For example, if the *buffer* is a UCS4 string + (:c:macro:`PyUnicode_4BYTE_KIND`) and it consists only of codepoints in + the UCS1 range, it will be transformed into UCS1 + (:c:macro:`PyUnicode_1BYTE_KIND`). + .. versionadded:: 3.3