From 60c85887b30f2b63a5a1a560ee78870f6b757076 Mon Sep 17 00:00:00 2001 From: RUANG Date: Tue, 25 Feb 2025 13:46:57 +0800 Subject: [PATCH 01/10] Add missing PyUnicode_Append() doc --- Doc/c-api/unicode.rst | 6 ++++++ Doc/data/refcounts.dat | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 8f383cd6c4015f..f102982bb24158 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -607,6 +607,12 @@ APIs: decref'ing the returned objects. +.. c:function:: void PyUnicode_Append(PyObject **p_left, PyObject *right) + + Append the string *right* to the end of *p_left*. (In particular, a :exc:`SystemError` + if *p_left* or *right* is NULL, or if either is not a Unicode object). + + .. c:function:: Py_ssize_t PyUnicode_GetLength(PyObject *unicode) Return the length of the Unicode object, in code points. diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index a483c57cb2ce06..da398a764038b2 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -2757,6 +2757,10 @@ PyUnicode_FromFormatV:PyObject*::+1: PyUnicode_FromFormatV:const char*:format:: PyUnicode_FromFormatV:va_list:args:: +PyUnicode_Append:void::: +PyUnicode_ReadChar:PyObject**:p_left:0: +PyUnicode_ReadChar:PyObject*:right:: + PyUnicode_GetLength:Py_ssize_t::: PyUnicode_GetLength:PyObject*:unicode:0: From 3d054904634b83228e17c335c60bf540a81f4000 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Tue, 25 Feb 2025 13:50:18 +0800 Subject: [PATCH 02/10] Change the copied content --- Doc/data/refcounts.dat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index de674747749433..e56775b1d3a476 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -2771,8 +2771,8 @@ PyUnicode_FromFormatV:const char*:format:: PyUnicode_FromFormatV:va_list:args:: PyUnicode_Append:void::: -PyUnicode_ReadChar:PyObject**:p_left:0: -PyUnicode_ReadChar:PyObject*:right:: +PyUnicode_Append:PyObject**:p_left:0: +PyUnicode_Append:PyObject*:right:: PyUnicode_GetDefaultEncoding:const char*::: PyUnicode_GetDefaultEncoding::void:: From 8f57a624a94fb3ef78f9ed6485a1c1421fdc313f Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Tue, 25 Feb 2025 13:51:27 +0800 Subject: [PATCH 03/10] Add '`` ``' --- Doc/c-api/unicode.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 4166cd03214ae7..ed3cc684a2c272 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -610,7 +610,7 @@ APIs: .. c:function:: void PyUnicode_Append(PyObject **p_left, PyObject *right) Append the string *right* to the end of *p_left*. (In particular, a :exc:`SystemError` - if *p_left* or *right* is NULL, or if either is not a Unicode object). + if *p_left* or *right* is ``NULL``, or if either is not a Unicode object). .. c:function:: const char* PyUnicode_GetDefaultEncoding(void) From eb7a478b3a729d1dd991e1f2a9792de47b544326 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Wed, 26 Feb 2025 12:42:29 +0800 Subject: [PATCH 04/10] Change doc --- 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 ed3cc684a2c272..987344cef521de 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -609,8 +609,10 @@ APIs: .. c:function:: void PyUnicode_Append(PyObject **p_left, PyObject *right) - Append the string *right* to the end of *p_left*. (In particular, a :exc:`SystemError` - if *p_left* or *right* is ``NULL``, or if either is not a Unicode object). + Append the string *right* to the end of *p_left*. + *p_left* must point to a :term:`strong reference` to a Unicode object. + + On error, set *p_left* to ``NULL`` and set an exception. .. c:function:: const char* PyUnicode_GetDefaultEncoding(void) From 56129b2f2ab77e7742712877cea39e0260d2b1c5 Mon Sep 17 00:00:00 2001 From: RUANG Date: Thu, 27 Feb 2025 19:34:39 +0800 Subject: [PATCH 05/10] Add PyUnicode_AppendAndDel function doc --- 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 987344cef521de..b5536e6101539b 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -615,6 +615,12 @@ APIs: On error, set *p_left* to ``NULL`` and set an exception. +.. c:function:: void PyUnicode_AppendAndDel(PyObject **p_left, PyObject *right) + + The function is identical to :c:func:`PyUnicode_Append`, with the only + difference being that it decrements the reference count of *right* by one. + + .. c:function:: const char* PyUnicode_GetDefaultEncoding(void) Return the name of the default string encoding, ``"utf-8"``. From eb0cba1383d97c0a6253bf6870aca36147bd0fa6 Mon Sep 17 00:00:00 2001 From: RUANG Date: Fri, 28 Feb 2025 11:36:10 +0800 Subject: [PATCH 06/10] Change doc --- Doc/c-api/unicode.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index b5536e6101539b..302dd503159bfa 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -612,7 +612,7 @@ APIs: Append the string *right* to the end of *p_left*. *p_left* must point to a :term:`strong reference` to a Unicode object. - On error, set *p_left* to ``NULL`` and set an exception. + On error, set *p_left* to ``NULL`` (*stealing* the reference) and set an exception. .. c:function:: void PyUnicode_AppendAndDel(PyObject **p_left, PyObject *right) From d8cc5d56993c3652df3df78de3671e65500f84b6 Mon Sep 17 00:00:00 2001 From: RUANG Date: Fri, 28 Feb 2025 11:39:04 +0800 Subject: [PATCH 07/10] Add PyUnicode_AppendAndDel to refcounts --- Doc/data/refcounts.dat | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index e56775b1d3a476..14629fbff0fb78 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -2774,6 +2774,10 @@ PyUnicode_Append:void::: PyUnicode_Append:PyObject**:p_left:0: PyUnicode_Append:PyObject*:right:: +PyUnicode_AppendAndDel:void::: +PyUnicode_AppendAndDel:PyObject**:p_left:0: +PyUnicode_AppendAndDel:PyObject*:right:-1: + PyUnicode_GetDefaultEncoding:const char*::: PyUnicode_GetDefaultEncoding::void:: From ccc56d4c03433b21dc04374963279acee97781e7 Mon Sep 17 00:00:00 2001 From: RUANG Date: Sat, 1 Mar 2025 09:06:51 +0800 Subject: [PATCH 08/10] Change doc --- 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 302dd503159bfa..51da111a14bc2e 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -612,12 +612,12 @@ APIs: Append the string *right* to the end of *p_left*. *p_left* must point to a :term:`strong reference` to a Unicode object. - On error, set *p_left* to ``NULL`` (*stealing* the reference) and set an exception. + On error, set *\*p_left* to ``NULL`` and set an exception. .. c:function:: void PyUnicode_AppendAndDel(PyObject **p_left, PyObject *right) - The function is identical to :c:func:`PyUnicode_Append`, with the only + The function is similar to :c:func:`PyUnicode_Append`, with the only difference being that it decrements the reference count of *right* by one. From 24129a0885709ab5a9290d5d739e632abc50b3c9 Mon Sep 17 00:00:00 2001 From: "RUANG (James Roy)" Date: Tue, 11 Mar 2025 11:33:15 +0800 Subject: [PATCH 09/10] Change doc Co-authored-by: Petr Viktorin --- 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 51da111a14bc2e..19cc0a04e377d7 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -608,12 +608,14 @@ APIs: .. c:function:: void PyUnicode_Append(PyObject **p_left, PyObject *right) - Append the string *right* to the end of *p_left*. - *p_left* must point to a :term:`strong reference` to a Unicode object. + *p_left* must point to a :term:`strong reference` to a Unicode object; + :c:func:`!PyUnicode_Append` releases ("steals") this reference. On error, set *\*p_left* to ``NULL`` and set an exception. + On sucess, set *\*p_left* to a new strong reference to the result. + .. c:function:: void PyUnicode_AppendAndDel(PyObject **p_left, PyObject *right) From 0191be037b3f8a6b8a8eac75a2bd6a96b294404e Mon Sep 17 00:00:00 2001 From: RUANG Date: Tue, 11 Mar 2025 15:12:25 +0800 Subject: [PATCH 10/10] Change doc --- Doc/c-api/unicode.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 19cc0a04e377d7..e7905e0a95b64e 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -608,6 +608,7 @@ APIs: .. c:function:: void PyUnicode_Append(PyObject **p_left, PyObject *right) + Append the string *right* to the end of *p_left*. *p_left* must point to a :term:`strong reference` to a Unicode object; :c:func:`!PyUnicode_Append` releases ("steals") this reference.