Skip to content

Commit 577fc04

Browse files
authored
[3.6] bpo-29549: Fixes docstring for str.index (GH-256) (GH-1028)
(cherry picked from commit 43ba886)
1 parent 90eb7a9 commit 577fc04

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

Objects/bytes_methods.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,11 @@ _Py_bytes_find(const char *str, Py_ssize_t len, PyObject *args)
542542
PyDoc_STRVAR_shared(_Py_index__doc__,
543543
"B.index(sub[, start[, end]]) -> int\n\
544544
\n\
545-
Like B.find() but raise ValueError when the subsection is not found.");
545+
Return the lowest index in B where subsection sub is found,\n\
546+
such that sub is contained within B[start,end]. Optional\n\
547+
arguments start and end are interpreted as in slice notation.\n\
548+
\n\
549+
Raises ValueError when the subsection is not found.");
546550

547551
PyObject *
548552
_Py_bytes_index(const char *str, Py_ssize_t len, PyObject *args)
@@ -579,7 +583,11 @@ _Py_bytes_rfind(const char *str, Py_ssize_t len, PyObject *args)
579583
PyDoc_STRVAR_shared(_Py_rindex__doc__,
580584
"B.rindex(sub[, start[, end]]) -> int\n\
581585
\n\
582-
Like B.rfind() but raise ValueError when the subsection is not found.");
586+
Return the highest index in B where subsection sub is found,\n\
587+
such that sub is contained within B[start,end]. Optional\n\
588+
arguments start and end are interpreted as in slice notation.\n\
589+
\n\
590+
Raise ValueError when the subsection is not found.");
583591

584592
PyObject *
585593
_Py_bytes_rindex(const char *str, Py_ssize_t len, PyObject *args)
@@ -811,4 +819,3 @@ PyDoc_STRVAR_shared(_Py_zfill__doc__,
811819
"\n"
812820
"Pad a numeric string B with zeros on the left, to fill a field\n"
813821
"of the specified width. B is never truncated.");
814-

Objects/unicodeobject.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11701,7 +11701,11 @@ unicode_hash(PyObject *self)
1170111701
PyDoc_STRVAR(index__doc__,
1170211702
"S.index(sub[, start[, end]]) -> int\n\
1170311703
\n\
11704-
Like S.find() but raise ValueError when the substring is not found.");
11704+
Return the lowest index in S where substring sub is found, \n\
11705+
such that sub is contained within S[start:end]. Optional\n\
11706+
arguments start and end are interpreted as in slice notation.\n\
11707+
\n\
11708+
Raises ValueError when the substring is not found.");
1170511709

1170611710
static PyObject *
1170711711
unicode_index(PyObject *self, PyObject *args)
@@ -12758,7 +12762,11 @@ unicode_rfind(PyObject *self, PyObject *args)
1275812762
PyDoc_STRVAR(rindex__doc__,
1275912763
"S.rindex(sub[, start[, end]]) -> int\n\
1276012764
\n\
12761-
Like S.rfind() but raise ValueError when the substring is not found.");
12765+
Return the highest index in S where substring sub is found,\n\
12766+
such that sub is contained within S[start:end]. Optional\n\
12767+
arguments start and end are interpreted as in slice notation.\n\
12768+
\n\
12769+
Raises ValueError when the substring is not found.");
1276212770

1276312771
static PyObject *
1276412772
unicode_rindex(PyObject *self, PyObject *args)

0 commit comments

Comments
 (0)