From c8d2ceeaa46aaf7e1282de0d23514739da8ad1f2 Mon Sep 17 00:00:00 2001 From: Yash Date: Wed, 7 Jan 2026 01:14:57 +0530 Subject: [PATCH 1/6] unicode doc 1 --- Doc/c-api/unicode.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index ca7c8bb11a5d78..356851f3b13c6c 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -129,6 +129,20 @@ access to internal read-only data of Unicode objects: .. versionadded:: 3.3 +.. c:macro:: PyUnicode_IS_COMPACT(o) + + Return true if the Unicode object *o* is a compact string. + + .. versionadded:: 3.3 + + +.. c:macro:: PyUnicode_IS_COMPACT_ASCII(o) + + Return true if the Unicode object *o* is a compact ASCII string. + + .. versionadded:: 3.3 + + .. c:function:: void PyUnicode_WRITE(int kind, void *data, \ Py_ssize_t index, Py_UCS4 value) From 26e9725fb6b6aa6363d143f19e1f47278d0450aa Mon Sep 17 00:00:00 2001 From: Yash Date: Wed, 7 Jan 2026 01:37:01 +0530 Subject: [PATCH 2/6] fix 1 unicode --- Doc/c-api/unicode.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 356851f3b13c6c..066513232677f4 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -132,14 +132,16 @@ access to internal read-only data of Unicode objects: .. c:macro:: PyUnicode_IS_COMPACT(o) Return true if the Unicode object *o* is a compact string. - + Compact strings use a single memory block for + the structure and the character data. .. versionadded:: 3.3 .. c:macro:: PyUnicode_IS_COMPACT_ASCII(o) Return true if the Unicode object *o* is a compact ASCII string. - + A compact ASCII string uses a single memory block + and contains only ASCII characters. .. versionadded:: 3.3 From 6815686a345476e3707381e3754399102b52b103 Mon Sep 17 00:00:00 2001 From: Yash Date: Wed, 7 Jan 2026 16:05:35 +0530 Subject: [PATCH 3/6] fix 2 unicode --- Doc/c-api/unicode.rst | 8 ++++---- Tools/check-c-api-docs/ignored_c_api.txt | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 066513232677f4..502e8c40c55869 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -132,16 +132,16 @@ access to internal read-only data of Unicode objects: .. c:macro:: PyUnicode_IS_COMPACT(o) Return true if the Unicode object *o* is a compact string. - Compact strings use a single memory block for - the structure and the character data. + Compact strings use the :c:struct:`PyCompactUnicodeObject` structure. + .. versionadded:: 3.3 .. c:macro:: PyUnicode_IS_COMPACT_ASCII(o) Return true if the Unicode object *o* is a compact ASCII string. - A compact ASCII string uses a single memory block - and contains only ASCII characters. + Compact ASCII strings use the :c:struct:`PyASCIIObject` structure. + .. versionadded:: 3.3 diff --git a/Tools/check-c-api-docs/ignored_c_api.txt b/Tools/check-c-api-docs/ignored_c_api.txt index e81ffd51e193b2..4f4626b9d2681a 100644 --- a/Tools/check-c-api-docs/ignored_c_api.txt +++ b/Tools/check-c-api-docs/ignored_c_api.txt @@ -89,5 +89,4 @@ PyUnstable_EXECUTABLE_KIND_SKIP # cpython/pylifecycle.h Py_FrozenMain # cpython/unicodeobject.h -PyUnicode_IS_COMPACT -PyUnicode_IS_COMPACT_ASCII + From c0429a13d3463aa5f08b98f4612a56889bc3a063 Mon Sep 17 00:00:00 2001 From: Yash Date: Wed, 7 Jan 2026 20:36:13 +0530 Subject: [PATCH 4/6] unicode fix 3 --- Doc/c-api/unicode.rst | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 502e8c40c55869..77c9965eeb3320 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -65,6 +65,22 @@ Python: .. versionadded:: 3.3 +.. c:macro:: PyUnicode_IS_COMPACT(o) + + Return true if the Unicode object *o* is a compact string. + Compact strings use the :c:struct:`PyCompactUnicodeObject` structure. + + .. versionadded:: 3.3 + + +.. c:macro:: PyUnicode_IS_COMPACT_ASCII(o) + + Return true if the Unicode object *o* is a compact ASCII string. + Compact ASCII strings use the :c:struct:`PyASCIIObject` structure. + + .. versionadded:: 3.3 + + The following APIs are C macros and static inlined functions for fast checks and access to internal read-only data of Unicode objects: @@ -129,22 +145,6 @@ access to internal read-only data of Unicode objects: .. versionadded:: 3.3 -.. c:macro:: PyUnicode_IS_COMPACT(o) - - Return true if the Unicode object *o* is a compact string. - Compact strings use the :c:struct:`PyCompactUnicodeObject` structure. - - .. versionadded:: 3.3 - - -.. c:macro:: PyUnicode_IS_COMPACT_ASCII(o) - - Return true if the Unicode object *o* is a compact ASCII string. - Compact ASCII strings use the :c:struct:`PyASCIIObject` structure. - - .. versionadded:: 3.3 - - .. c:function:: void PyUnicode_WRITE(int kind, void *data, \ Py_ssize_t index, Py_UCS4 value) From a93440434c74bdab734a223a8e1ddecc70394c88 Mon Sep 17 00:00:00 2001 From: Yashraj Date: Thu, 8 Jan 2026 22:28:21 +0530 Subject: [PATCH 5/6] unicode fix 4 Co-authored-by: Petr Viktorin --- Doc/c-api/unicode.rst | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 77c9965eeb3320..025d83e2af7c99 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -65,22 +65,27 @@ Python: .. versionadded:: 3.3 -.. c:macro:: PyUnicode_IS_COMPACT(o) + The structure of a particular object can be determined using the following + macros. + The macros cannot fail; their behavior is undefined if their argument + is not a Python Unicode object. - Return true if the Unicode object *o* is a compact string. - Compact strings use the :c:struct:`PyCompactUnicodeObject` structure. + .. c:namespace:: NULL - .. versionadded:: 3.3 + .. c:macro:: PyUnicode_IS_COMPACT(o) + True if *o* uses the :c:struct:`PyCompactUnicodeObject` structure. -.. c:macro:: PyUnicode_IS_COMPACT_ASCII(o) + .. versionadded:: 3.3 - Return true if the Unicode object *o* is a compact ASCII string. - Compact ASCII strings use the :c:struct:`PyASCIIObject` structure. - .. versionadded:: 3.3 + .. c:macro:: PyUnicode_IS_COMPACT_ASCII(o) + + True if *o* uses the :c:struct:`PyASCIIObject` structure. + .. versionadded:: 3.3 + The following APIs are C macros and static inlined functions for fast checks and access to internal read-only data of Unicode objects: From 03589fca69330baa13fbf3346a3b4da885b90b6c Mon Sep 17 00:00:00 2001 From: Yash Date: Thu, 8 Jan 2026 22:34:41 +0530 Subject: [PATCH 6/6] unicode fix 5 --- Doc/c-api/unicode.rst | 2 +- Tools/check-c-api-docs/ignored_c_api.txt | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 025d83e2af7c99..d2b6643c700e88 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -85,7 +85,7 @@ Python: .. versionadded:: 3.3 - + The following APIs are C macros and static inlined functions for fast checks and access to internal read-only data of Unicode objects: diff --git a/Tools/check-c-api-docs/ignored_c_api.txt b/Tools/check-c-api-docs/ignored_c_api.txt index 4f4626b9d2681a..ee9bca87b3c5ea 100644 --- a/Tools/check-c-api-docs/ignored_c_api.txt +++ b/Tools/check-c-api-docs/ignored_c_api.txt @@ -87,6 +87,4 @@ PyUnstable_EXECUTABLE_KIND_METHOD_DESCRIPTOR PyUnstable_EXECUTABLE_KIND_PY_FUNCTION PyUnstable_EXECUTABLE_KIND_SKIP # cpython/pylifecycle.h -Py_FrozenMain -# cpython/unicodeobject.h - +Py_FrozenMain \ No newline at end of file