From 581fc81c501c0f7d4756bf4d85b1f8feaa29a54d Mon Sep 17 00:00:00 2001 From: Aryan Yadav Date: Wed, 24 Jun 2026 21:02:25 +0530 Subject: [PATCH 1/3] gh-152030: Clarify sequence.index() signature Updated the method signature for sequence.index to use the positional-only marker (/), replacing the old bracket syntax. Fixes #152030 --- Doc/library/stdtypes.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index a47e1ffb1a6afb..4e6eb30b275ad9 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*. From b3687b4c0216cd4b48e187981de7f5695aef7707 Mon Sep 17 00:00:00 2001 From: Aryan Yadav Date: Thu, 25 Jun 2026 01:13:40 +0530 Subject: [PATCH 2/3] Fix str.index() signature generation in Argument Clinic --- Objects/unicodeobject.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 3c689761de9b19..71e7137ff177ae 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)); From 3dbeecca496f41250a1f082254bd3e2c79195242 Mon Sep 17 00:00:00 2001 From: Aryan Yadav Date: Thu, 25 Jun 2026 01:28:53 +0530 Subject: [PATCH 3/3] Add missing generated clinic header file --- Objects/clinic/unicodeobject.c.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h index d0753b38843fcc..5a967c0f633302 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]*/