Fix bad grammar and import docstring for split/rsplit (GH-32381)

This commit is contained in:
Raymond Hettinger 2022-04-08 08:36:20 -05:00 committed by GitHub
parent 1c2fddddae
commit d6fb104690
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 22 deletions

View File

@ -858,15 +858,21 @@ PyDoc_STRVAR(unicode_split__doc__,
"split($self, /, sep=None, maxsplit=-1)\n" "split($self, /, sep=None, maxsplit=-1)\n"
"--\n" "--\n"
"\n" "\n"
"Return a list of the words in the string, using sep as the delimiter string.\n" "Return a list of the substrings in the string, using sep as the separator string.\n"
"\n" "\n"
" sep\n" " sep\n"
" The delimiter according which to split the string.\n" " The separator used to split the string.\n"
" None (the default value) means split according to any whitespace,\n" "\n"
" and discard empty strings from the result.\n" " When set to None (the default value), will split on any whitespace\n"
" character (including \\\\n \\\\r \\\\t \\\\f and spaces) and will discard\n"
" empty strings from the result.\n"
" maxsplit\n" " maxsplit\n"
" Maximum number of splits to do.\n" " Maximum number of splits (starting from the left).\n"
" -1 (the default value) means no limit."); " -1 (the default value) means no limit.\n"
"\n"
"Note, str.split() is mainly useful for data that has been intentionally\n"
"delimited. With natural text that includes punctuation, consider using\n"
"the regular expression module.");
#define UNICODE_SPLIT_METHODDEF \ #define UNICODE_SPLIT_METHODDEF \
{"split", (PyCFunction)(void(*)(void))unicode_split, METH_FASTCALL|METH_KEYWORDS, unicode_split__doc__}, {"split", (PyCFunction)(void(*)(void))unicode_split, METH_FASTCALL|METH_KEYWORDS, unicode_split__doc__},
@ -953,17 +959,19 @@ PyDoc_STRVAR(unicode_rsplit__doc__,
"rsplit($self, /, sep=None, maxsplit=-1)\n" "rsplit($self, /, sep=None, maxsplit=-1)\n"
"--\n" "--\n"
"\n" "\n"
"Return a list of the words in the string, using sep as the delimiter string.\n" "Return a list of the substrings in the string, using sep as the separator string.\n"
"\n" "\n"
" sep\n" " sep\n"
" The delimiter according which to split the string.\n" " The separator used to split the string.\n"
" None (the default value) means split according to any whitespace,\n" "\n"
" and discard empty strings from the result.\n" " When set to None (the default value), will split on any whitespace\n"
" character (including \\\\n \\\\r \\\\t \\\\f and spaces) and will discard\n"
" empty strings from the result.\n"
" maxsplit\n" " maxsplit\n"
" Maximum number of splits to do.\n" " Maximum number of splits (starting from the left).\n"
" -1 (the default value) means no limit.\n" " -1 (the default value) means no limit.\n"
"\n" "\n"
"Splits are done starting at the end of the string and working to the front."); "Splitting starts at the end of the string and works to the front.");
#define UNICODE_RSPLIT_METHODDEF \ #define UNICODE_RSPLIT_METHODDEF \
{"rsplit", (PyCFunction)(void(*)(void))unicode_rsplit, METH_FASTCALL|METH_KEYWORDS, unicode_rsplit__doc__}, {"rsplit", (PyCFunction)(void(*)(void))unicode_rsplit, METH_FASTCALL|METH_KEYWORDS, unicode_rsplit__doc__},
@ -1327,4 +1335,4 @@ skip_optional_pos:
exit: exit:
return return_value; return return_value;
} }
/*[clinic end generated code: output=f10cf85d3935b3b7 input=a9049054013a1b77]*/ /*[clinic end generated code: output=c494bed46209961d input=a9049054013a1b77]*/

View File

@ -13155,19 +13155,26 @@ PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
str.split as unicode_split str.split as unicode_split
sep: object = None sep: object = None
The delimiter according which to split the string. The separator used to split the string.
None (the default value) means split according to any whitespace,
and discard empty strings from the result. When set to None (the default value), will split on any whitespace
character (including \\n \\r \\t \\f and spaces) and will discard
empty strings from the result.
maxsplit: Py_ssize_t = -1 maxsplit: Py_ssize_t = -1
Maximum number of splits to do. Maximum number of splits (starting from the left).
-1 (the default value) means no limit. -1 (the default value) means no limit.
Return a list of the words in the string, using sep as the delimiter string. Return a list of the substrings in the string, using sep as the separator string.
Note, str.split() is mainly useful for data that has been intentionally
delimited. With natural text that includes punctuation, consider using
the regular expression module.
[clinic start generated code]*/ [clinic start generated code]*/
static PyObject * static PyObject *
unicode_split_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit) unicode_split_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit)
/*[clinic end generated code: output=3a65b1db356948dc input=606e750488a82359]*/ /*[clinic end generated code: output=3a65b1db356948dc input=906d953b44efc43b]*/
{ {
if (sep == Py_None) if (sep == Py_None)
return split(self, NULL, maxsplit); return split(self, NULL, maxsplit);
@ -13338,14 +13345,14 @@ PyUnicode_RSplit(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
/*[clinic input] /*[clinic input]
str.rsplit as unicode_rsplit = str.split str.rsplit as unicode_rsplit = str.split
Return a list of the words in the string, using sep as the delimiter string. Return a list of the substrings in the string, using sep as the separator string.
Splits are done starting at the end of the string and working to the front. Splitting starts at the end of the string and works to the front.
[clinic start generated code]*/ [clinic start generated code]*/
static PyObject * static PyObject *
unicode_rsplit_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit) unicode_rsplit_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit)
/*[clinic end generated code: output=c2b815c63bcabffc input=12ad4bf57dd35f15]*/ /*[clinic end generated code: output=c2b815c63bcabffc input=ea78406060fce33c]*/
{ {
if (sep == Py_None) if (sep == Py_None)
return rsplit(self, NULL, maxsplit); return rsplit(self, NULL, maxsplit);