Mailing List Archive

gh-117431: Fix str.endswith docstring (#117499)
https://github.com/python/cpython/commit/1dc1521042d5e750b4a129ac8dd439edafed6783
commit: 1dc1521042d5e750b4a129ac8dd439edafed6783
branch: main
author: Erlend E. Aasland <erlend@python.org>
committer: erlend-aasland <erlend.aasland@protonmail.com>
date: 2024-04-03T12:33:20+02:00
summary:

gh-117431: Fix str.endswith docstring (#117499)

The first parameter is named 'suffix', not 'prefix'.

Regression introduced by commit 444156ed

files:
M Objects/clinic/unicodeobject.c.h
M Objects/unicodeobject.c

diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h
index c956bb1936776a..3f6dd8b93a7155 100644
--- a/Objects/clinic/unicodeobject.c.h
+++ b/Objects/clinic/unicodeobject.c.h
@@ -1421,12 +1421,12 @@ unicode_startswith(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
}

PyDoc_STRVAR(unicode_endswith__doc__,
-"endswith($self, prefix[, start[, end]], /)\n"
+"endswith($self, suffix[, start[, end]], /)\n"
"--\n"
"\n"
-"Return True if the string ends with the specified prefix, False otherwise.\n"
+"Return True if the string ends with the specified suffix, False otherwise.\n"
"\n"
-" prefix\n"
+" suffix\n"
" A string or a tuple of strings to try.\n"
" start\n"
" Optional start position. Default: start of the string.\n"
@@ -1609,4 +1609,4 @@ unicode_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=e495e878d8283217 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=1734aa1fcc9b076a input=a9049054013a1b77]*/
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index ac59419b3c7a50..eb83312e9c3a69 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -13078,16 +13078,24 @@ unicode_startswith_impl(PyObject *self, PyObject *subobj, Py_ssize_t start,


/*[clinic input]
-@text_signature "($self, prefix[, start[, end]], /)"
-str.endswith as unicode_endswith = str.startswith
+@text_signature "($self, suffix[, start[, end]], /)"
+str.endswith as unicode_endswith
+
+ suffix as subobj: object
+ A string or a tuple of strings to try.
+ start: slice_index(accept={int, NoneType}, c_default='0') = None
+ Optional start position. Default: start of the string.
+ end: slice_index(accept={int, NoneType}, c_default='PY_SSIZE_T_MAX') = None
+ Optional stop position. Default: end of the string.
+ /

-Return True if the string ends with the specified prefix, False otherwise.
+Return True if the string ends with the specified suffix, False otherwise.
[clinic start generated code]*/

static PyObject *
unicode_endswith_impl(PyObject *self, PyObject *subobj, Py_ssize_t start,
Py_ssize_t end)
-/*[clinic end generated code: output=cce6f8ceb0102ca9 input=82cd5ce9e7623646]*/
+/*[clinic end generated code: output=cce6f8ceb0102ca9 input=00fbdc774a7d4d71]*/
{
if (PyTuple_Check(subobj)) {
Py_ssize_t i;

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-leave@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: list-python-checkins@lists.gossamer-threads.com