Skip to content

Commit d6fb104

Browse files
authored
Fix bad grammar and import docstring for split/rsplit (GH-32381)
1 parent 1c2fddd commit d6fb104

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

Objects/clinic/unicodeobject.c.h

Lines changed: 21 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/unicodeobject.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13155,19 +13155,26 @@ PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
1315513155
str.split as unicode_split
1315613156
1315713157
sep: object = None
13158-
The delimiter according which to split the string.
13159-
None (the default value) means split according to any whitespace,
13160-
and discard empty strings from the result.
13158+
The separator used to split the string.
13159+
13160+
When set to None (the default value), will split on any whitespace
13161+
character (including \\n \\r \\t \\f and spaces) and will discard
13162+
empty strings from the result.
1316113163
maxsplit: Py_ssize_t = -1
13162-
Maximum number of splits to do.
13164+
Maximum number of splits (starting from the left).
1316313165
-1 (the default value) means no limit.
1316413166
13165-
Return a list of the words in the string, using sep as the delimiter string.
13167+
Return a list of the substrings in the string, using sep as the separator string.
13168+
13169+
Note, str.split() is mainly useful for data that has been intentionally
13170+
delimited. With natural text that includes punctuation, consider using
13171+
the regular expression module.
13172+
1316613173
[clinic start generated code]*/
1316713174

1316813175
static PyObject *
1316913176
unicode_split_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit)
13170-
/*[clinic end generated code: output=3a65b1db356948dc input=606e750488a82359]*/
13177+
/*[clinic end generated code: output=3a65b1db356948dc input=906d953b44efc43b]*/
1317113178
{
1317213179
if (sep == Py_None)
1317313180
return split(self, NULL, maxsplit);
@@ -13338,14 +13345,14 @@ PyUnicode_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
1333813345
/*[clinic input]
1333913346
str.rsplit as unicode_rsplit = str.split
1334013347
13341-
Return a list of the words in the string, using sep as the delimiter string.
13348+
Return a list of the substrings in the string, using sep as the separator string.
1334213349
13343-
Splits are done starting at the end of the string and working to the front.
13350+
Splitting starts at the end of the string and works to the front.
1334413351
[clinic start generated code]*/
1334513352

1334613353
static PyObject *
1334713354
unicode_rsplit_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit)
13348-
/*[clinic end generated code: output=c2b815c63bcabffc input=12ad4bf57dd35f15]*/
13355+
/*[clinic end generated code: output=c2b815c63bcabffc input=ea78406060fce33c]*/
1334913356
{
1335013357
if (sep == Py_None)
1335113358
return rsplit(self, NULL, maxsplit);

0 commit comments

Comments
 (0)