diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index a47e1ffb1a6afb1..4e6eb30b275ad95 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1169,7 +1169,8 @@ Sequence types also support the following methods: :no-contents-entry: :no-index-entry: :no-typesetting: -.. method:: sequence.index(value[, start[, stop]]) +.. method:: sequence.index(value, /) + sequence.index(value, start=0, stop=sys.maxsize, /) Return the index of the first occurrence of *value* in *sequence*. diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h index d0753b38843fccf..5a967c0f633302a 100644 --- a/Objects/clinic/unicodeobject.c.h +++ b/Objects/clinic/unicodeobject.c.h @@ -138,7 +138,7 @@ unicode_center(PyObject *self, PyObject *const *args, Py_ssize_t nargs) } PyDoc_STRVAR(unicode_count__doc__, -"count($self, sub[, start[, end]], /)\n" +"count($self, sub, start=0, end=sys.maxsize, /)\n" "--\n" "\n" "Return the number of non-overlapping occurrences of substring sub in string S[start:end].\n" @@ -365,7 +365,7 @@ unicode_expandtabs(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb } PyDoc_STRVAR(unicode_find__doc__, -"find($self, sub[, start[, end]], /)\n" +"find($self, sub, start=0, end=sys.maxsize, /)\n" "--\n" "\n" "Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].\n" @@ -421,7 +421,7 @@ unicode_find(PyObject *str, PyObject *const *args, Py_ssize_t nargs) } PyDoc_STRVAR(unicode_index__doc__, -"index($self, sub[, start[, end]], /)\n" +"index($self, sub, start=0, end=sys.maxsize, /)\n" "--\n" "\n" "Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].\n" @@ -1072,7 +1072,7 @@ unicode_removesuffix(PyObject *self, PyObject *arg) } PyDoc_STRVAR(unicode_rfind__doc__, -"rfind($self, sub[, start[, end]], /)\n" +"rfind($self, sub, start=0, end=sys.maxsize, /)\n" "--\n" "\n" "Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].\n" @@ -1128,7 +1128,7 @@ unicode_rfind(PyObject *str, PyObject *const *args, Py_ssize_t nargs) } PyDoc_STRVAR(unicode_rindex__doc__, -"rindex($self, sub[, start[, end]], /)\n" +"rindex($self, sub, start=0, end=sys.maxsize, /)\n" "--\n" "\n" "Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].\n" @@ -1916,4 +1916,4 @@ unicode_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=9d243c63e951e31d input=a9049054013a1b77]*/ +/*[clinic end generated code: output=bee76c3a598ef563 input=a9049054013a1b77]*/ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 3c689761de9b199..71e7137ff177ae9 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -11429,13 +11429,12 @@ PyUnicode_AppendAndDel(PyObject **pleft, PyObject *right) /*[clinic input] @permit_long_summary -@text_signature "($self, sub[, start[, end]], /)" str.count as unicode_count -> Py_ssize_t self as str: self sub as substr: unicode - start: slice_index(accept={int, NoneType}, c_default='0') = None - end: slice_index(accept={int, NoneType}, c_default='PY_SSIZE_T_MAX') = None + start: slice_index(accept={int, NoneType}, c_default='0') = 0 + end: slice_index(accept={int, NoneType}, c_default='PY_SSIZE_T_MAX') = sys.maxsize / Return the number of non-overlapping occurrences of substring sub in string S[start:end]. @@ -11447,7 +11446,7 @@ notation. static Py_ssize_t unicode_count_impl(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end) -/*[clinic end generated code: output=8fcc3aef0b18edbf input=c9209e05438cc352]*/ +/*[clinic end generated code: output=8fcc3aef0b18edbf input=66a5213425fc7a42]*/ { assert(PyUnicode_Check(str)); assert(PyUnicode_Check(substr));