Skip to content

Commit 5c0aba0

Browse files
miss-islingtoncdce8pencukou
authored
[3.12] gh-46236: Document PyUnicode_RSplit, PyUnicode_Partition and PyUnicode_RPartition (GH-130191) (#130361)
gh-46236: Document PyUnicode_RSplit, PyUnicode_Partition and PyUnicode_RPartition (GH-130191) (cherry picked from commit 0f5b821) Co-authored-by: Marc Mueller <[email protected]> Co-authored-by: Petr Viktorin <[email protected]>
1 parent ecfca20 commit 5c0aba0

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

Doc/c-api/unicode.rst

+41
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,20 @@ They all return ``NULL`` or ``-1`` if an exception occurs.
13761376
separator. At most *maxsplit* splits will be done. If negative, no limit is
13771377
set. Separators are not included in the resulting list.
13781378
1379+
On error, return ``NULL`` with an exception set.
1380+
1381+
Equivalent to :py:meth:`str.split`.
1382+
1383+
1384+
.. c:function:: PyObject* PyUnicode_RSplit(PyObject *unicode, PyObject *sep, Py_ssize_t maxsplit)
1385+
1386+
Similar to :c:func:`PyUnicode_Split`, but splitting will be done beginning
1387+
at the end of the string.
1388+
1389+
On error, return ``NULL`` with an exception set.
1390+
1391+
Equivalent to :py:meth:`str.rsplit`.
1392+
13791393
13801394
.. c:function:: PyObject* PyUnicode_Splitlines(PyObject *unicode, int keepends)
13811395
@@ -1384,6 +1398,33 @@ They all return ``NULL`` or ``-1`` if an exception occurs.
13841398
characters are not included in the resulting strings.
13851399
13861400
1401+
.. c:function:: PyObject* PyUnicode_Partition(PyObject *unicode, PyObject *sep)
1402+
1403+
Split a Unicode string at the first occurrence of *sep*, and return
1404+
a 3-tuple containing the part before the separator, the separator itself,
1405+
and the part after the separator. If the separator is not found,
1406+
return a 3-tuple containing the string itself, followed by two empty strings.
1407+
1408+
*sep* must not be empty.
1409+
1410+
On error, return ``NULL`` with an exception set.
1411+
1412+
Equivalent to :py:meth:`str.partition`.
1413+
1414+
1415+
.. c:function:: PyObject* PyUnicode_RPartition(PyObject *unicode, PyObject *sep)
1416+
1417+
Similar to :c:func:`PyUnicode_Partition`, but split a Unicode string at the
1418+
last occurrence of *sep*. If the separator is not found, return a 3-tuple
1419+
containing two empty strings, followed by the string itself.
1420+
1421+
*sep* must not be empty.
1422+
1423+
On error, return ``NULL`` with an exception set.
1424+
1425+
Equivalent to :py:meth:`str.rpartition`.
1426+
1427+
13871428
.. c:function:: PyObject* PyUnicode_Join(PyObject *separator, PyObject *seq)
13881429
13891430
Join a sequence of strings using the given *separator* and return the resulting

Doc/data/refcounts.dat

+16-3
Original file line numberDiff line numberDiff line change
@@ -2640,13 +2640,26 @@ PyUnicode_Concat:PyObject*::+1:
26402640
PyUnicode_Concat:PyObject*:left:0:
26412641
PyUnicode_Concat:PyObject*:right:0:
26422642

2643+
PyUnicode_Partition:PyObject*::+1:
2644+
PyUnicode_Partition:PyObject*:unicode:0:
2645+
PyUnicode_Partition:PyObject*:sep:0:
2646+
2647+
PyUnicode_RPartition:PyObject*::+1:
2648+
PyUnicode_RPartition:PyObject*:unicode:0:
2649+
PyUnicode_RPartition:PyObject*:sep:0:
2650+
2651+
PyUnicode_RSplit:PyObject*::+1:
2652+
PyUnicode_RSplit:PyObject*:unicode:0:
2653+
PyUnicode_RSplit:PyObject*:sep:0:
2654+
PyUnicode_RSplit:Py_ssize_t:maxsplit::
2655+
26432656
PyUnicode_Split:PyObject*::+1:
2644-
PyUnicode_Split:PyObject*:left:0:
2645-
PyUnicode_Split:PyObject*:right:0:
2657+
PyUnicode_Split:PyObject*:unicode:0:
2658+
PyUnicode_Split:PyObject*:sep:0:
26462659
PyUnicode_Split:Py_ssize_t:maxsplit::
26472660

26482661
PyUnicode_Splitlines:PyObject*::+1:
2649-
PyUnicode_Splitlines:PyObject*:s:0:
2662+
PyUnicode_Splitlines:PyObject*:unicode:0:
26502663
PyUnicode_Splitlines:int:keepend::
26512664

26522665
PyUnicode_Translate:PyObject*::+1:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
C API: Document :c:func:`PyUnicode_RSplit`, :c:func:`PyUnicode_Partition` and
2+
:c:func:`PyUnicode_RPartition`.

0 commit comments

Comments
 (0)