mirror of https://github.com/python/cpython
Fix bugf in index -- last char would not be checked.
This commit is contained in:
parent
a4ddbd885e
commit
66a07c07a5
|
@ -83,7 +83,7 @@ def splitfields(s, sep):
|
||||||
index_error = 'substring not found in string.index'
|
index_error = 'substring not found in string.index'
|
||||||
def index(s, sub):
|
def index(s, sub):
|
||||||
n = len(sub)
|
n = len(sub)
|
||||||
for i in range(len(s) - n):
|
for i in range(len(s) + 1 - n):
|
||||||
if sub = s[i:i+n]: return i
|
if sub = s[i:i+n]: return i
|
||||||
raise index_error, (s, sub)
|
raise index_error, (s, sub)
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ def splitfields(s, sep):
|
||||||
index_error = 'substring not found in string.index'
|
index_error = 'substring not found in string.index'
|
||||||
def index(s, sub):
|
def index(s, sub):
|
||||||
n = len(sub)
|
n = len(sub)
|
||||||
for i in range(len(s) - n):
|
for i in range(len(s) + 1 - n):
|
||||||
if sub = s[i:i+n]: return i
|
if sub = s[i:i+n]: return i
|
||||||
raise index_error, (s, sub)
|
raise index_error, (s, sub)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue