https://github.com/python/cpython/commit/2ac25550bde38babe396483635281e8bf2d65c14 commit: 2ac25550bde38babe396483635281e8bf2d65c14 branch: 3.13 author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com> committer: vstinner <vstin...@python.org> date: 2025-02-20T15:48:13Z summary:
[3.13] gh-46236: Document PyUnicode_RSplit, PyUnicode_Partition and PyUnicode_RPartition (GH-130191) (#130360) gh-46236: Document PyUnicode_RSplit, PyUnicode_Partition and PyUnicode_RPartition (GH-130191) (cherry picked from commit 0f5b82169e12321fd2294bf534496ad42a682ac4) Co-authored-by: Marc Mueller <30130371+cdc...@users.noreply.github.com> Co-authored-by: Petr Viktorin <encu...@gmail.com> files: A Misc/NEWS.d/next/Documentation/2025-02-16-14-57-00.gh-issue-46236.2HuS4S.rst M Doc/c-api/unicode.rst M Doc/data/refcounts.dat diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 31a801f412850c..d8652f7981d1ea 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -1398,6 +1398,20 @@ They all return ``NULL`` or ``-1`` if an exception occurs. separator. At most *maxsplit* splits will be done. If negative, no limit is set. Separators are not included in the resulting list. + On error, return ``NULL`` with an exception set. + + Equivalent to :py:meth:`str.split`. + + +.. c:function:: PyObject* PyUnicode_RSplit(PyObject *unicode, PyObject *sep, Py_ssize_t maxsplit) + + Similar to :c:func:`PyUnicode_Split`, but splitting will be done beginning + at the end of the string. + + On error, return ``NULL`` with an exception set. + + Equivalent to :py:meth:`str.rsplit`. + .. c:function:: PyObject* PyUnicode_Splitlines(PyObject *unicode, int keepends) @@ -1406,6 +1420,33 @@ They all return ``NULL`` or ``-1`` if an exception occurs. characters are not included in the resulting strings. +.. c:function:: PyObject* PyUnicode_Partition(PyObject *unicode, PyObject *sep) + + Split a Unicode string at the first occurrence of *sep*, and return + a 3-tuple containing the part before the separator, the separator itself, + and the part after the separator. If the separator is not found, + return a 3-tuple containing the string itself, followed by two empty strings. + + *sep* must not be empty. + + On error, return ``NULL`` with an exception set. + + Equivalent to :py:meth:`str.partition`. + + +.. c:function:: PyObject* PyUnicode_RPartition(PyObject *unicode, PyObject *sep) + + Similar to :c:func:`PyUnicode_Partition`, but split a Unicode string at the + last occurrence of *sep*. If the separator is not found, return a 3-tuple + containing two empty strings, followed by the string itself. + + *sep* must not be empty. + + On error, return ``NULL`` with an exception set. + + Equivalent to :py:meth:`str.rpartition`. + + .. c:function:: PyObject* PyUnicode_Join(PyObject *separator, PyObject *seq) Join a sequence of strings using the given *separator* and return the resulting diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index ae6c9f71ba9e92..448275fdb0aae7 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -2641,13 +2641,26 @@ PyUnicode_Concat:PyObject*::+1: PyUnicode_Concat:PyObject*:left:0: PyUnicode_Concat:PyObject*:right:0: +PyUnicode_Partition:PyObject*::+1: +PyUnicode_Partition:PyObject*:unicode:0: +PyUnicode_Partition:PyObject*:sep:0: + +PyUnicode_RPartition:PyObject*::+1: +PyUnicode_RPartition:PyObject*:unicode:0: +PyUnicode_RPartition:PyObject*:sep:0: + +PyUnicode_RSplit:PyObject*::+1: +PyUnicode_RSplit:PyObject*:unicode:0: +PyUnicode_RSplit:PyObject*:sep:0: +PyUnicode_RSplit:Py_ssize_t:maxsplit:: + PyUnicode_Split:PyObject*::+1: -PyUnicode_Split:PyObject*:left:0: -PyUnicode_Split:PyObject*:right:0: +PyUnicode_Split:PyObject*:unicode:0: +PyUnicode_Split:PyObject*:sep:0: PyUnicode_Split:Py_ssize_t:maxsplit:: PyUnicode_Splitlines:PyObject*::+1: -PyUnicode_Splitlines:PyObject*:s:0: +PyUnicode_Splitlines:PyObject*:unicode:0: PyUnicode_Splitlines:int:keepend:: PyUnicode_Translate:PyObject*::+1: diff --git a/Misc/NEWS.d/next/Documentation/2025-02-16-14-57-00.gh-issue-46236.2HuS4S.rst b/Misc/NEWS.d/next/Documentation/2025-02-16-14-57-00.gh-issue-46236.2HuS4S.rst new file mode 100644 index 00000000000000..0fc31a51be55f5 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2025-02-16-14-57-00.gh-issue-46236.2HuS4S.rst @@ -0,0 +1,2 @@ +C API: Document :c:func:`PyUnicode_RSplit`, :c:func:`PyUnicode_Partition` and +:c:func:`PyUnicode_RPartition`. _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com