From 131ecf5d63bea344f01bd516b57ad7ef958d9c19 Mon Sep 17 00:00:00 2001 From: Yuki Kobayashi Date: Tue, 10 Dec 2024 05:20:20 +0000 Subject: [PATCH 1/4] gh-46236: Add missing document of `PyUnicode_DecodeCodePageStateful` `PyUnicode_DecodeCodePageStateful` is in the limited C-API, and the document does not exist. --- Doc/c-api/unicode.rst | 7 +++++++ Doc/data/refcounts.dat | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index dcbc8804cd6b89..f1cf2912394c6d 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -1324,6 +1324,13 @@ the user settings on the machine running the codec. in *consumed*. +.. c:function:: PyObject* PyUnicode_DecodeCodePageStateful(int code_page, const char *str, \ + Py_ssize_t size, const char *errors, Py_ssize_t *consumed) + + Same as :c:func:`PyUnicode_DecodeMBCSStateful`, except that using the code page + specified by *code_page*. Use :c:macro:`!CP_ACP` code page to get the MBCS decoder. + + .. c:function:: PyObject* PyUnicode_AsMBCSString(PyObject *unicode) Encode a Unicode object using MBCS and return the result as Python bytes diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index e78754e24e23d8..a8a82c1e539944 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -2636,6 +2636,13 @@ PyUnicode_DecodeMBCSStateful:Py_ssize_t:size:: PyUnicode_DecodeMBCSStateful:const char*:errors:: PyUnicode_DecodeMBCSStateful:Py_ssize_t*:consumed:: +PyUnicode_DecodeCodePageStateful:PyObject*::+1: +PyUnicode_DecodeCodePageStateful:int:code_page:: +PyUnicode_DecodeCodePageStateful:const char*:s:: +PyUnicode_DecodeCodePageStateful:Py_ssize_t:size:: +PyUnicode_DecodeCodePageStateful:const char*:errors:: +PyUnicode_DecodeCodePageStateful:Py_ssize_t*:consumed:: + PyUnicode_EncodeCodePage:PyObject*::+1: PyUnicode_EncodeCodePage:int:code_page:: PyUnicode_EncodeCodePage:PyObject*:unicode:0: From 41dc6e4b185f6adf93d4d117265b0087ebc6df38 Mon Sep 17 00:00:00 2001 From: Yuki Kobayashi Date: Thu, 19 Dec 2024 13:51:57 +0900 Subject: [PATCH 2/4] Update Doc/c-api/unicode.rst Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- 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 f1cf2912394c6d..8ab9c808e238d4 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -1327,7 +1327,7 @@ the user settings on the machine running the codec. .. c:function:: PyObject* PyUnicode_DecodeCodePageStateful(int code_page, const char *str, \ Py_ssize_t size, const char *errors, Py_ssize_t *consumed) - Same as :c:func:`PyUnicode_DecodeMBCSStateful`, except that using the code page + Similar to :c:func:`PyUnicode_DecodeMBCSStateful`, except that using the code page specified by *code_page*. Use :c:macro:`!CP_ACP` code page to get the MBCS decoder. From 6740cb0374a90f29c48316a5d0d4ce6e0d441d95 Mon Sep 17 00:00:00 2001 From: Yuki Kobayashi Date: Sat, 11 Jan 2025 10:58:45 +0900 Subject: [PATCH 3/4] Update Doc/c-api/unicode.rst Co-authored-by: Peter Bierma --- 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 8ab9c808e238d4..0a73486f4ae11d 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -1327,7 +1327,7 @@ the user settings on the machine running the codec. .. c:function:: PyObject* PyUnicode_DecodeCodePageStateful(int code_page, const char *str, \ Py_ssize_t size, const char *errors, Py_ssize_t *consumed) - Similar to :c:func:`PyUnicode_DecodeMBCSStateful`, except that using the code page + Similar to :c:func:`PyUnicode_DecodeMBCSStateful`, except uses the code page specified by *code_page*. Use :c:macro:`!CP_ACP` code page to get the MBCS decoder. From b8351b4080d7b9c049eab9df88b3eceee7586663 Mon Sep 17 00:00:00 2001 From: Yuki Kobayashi Date: Sat, 11 Jan 2025 10:59:06 +0900 Subject: [PATCH 4/4] Update Doc/c-api/unicode.rst Co-authored-by: Peter Bierma --- 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 0a73486f4ae11d..4ab53fd0894381 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -1328,7 +1328,7 @@ the user settings on the machine running the codec. Py_ssize_t size, const char *errors, Py_ssize_t *consumed) Similar to :c:func:`PyUnicode_DecodeMBCSStateful`, except uses the code page - specified by *code_page*. Use :c:macro:`!CP_ACP` code page to get the MBCS decoder. + specified by *code_page*. .. c:function:: PyObject* PyUnicode_AsMBCSString(PyObject *unicode)