]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix bugf in index -- last char would not be checked.
authorGuido van Rossum <guido@python.org>
Wed, 26 Dec 1990 15:39:06 +0000 (15:39 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 26 Dec 1990 15:39:06 +0000 (15:39 +0000)
Lib/string.py
Lib/stringold.py

index 2a4feaebcc0b75aac24e3a3b276c7ccd3f9da231..3790357f1b5f50a54a8c3a5fe919c68443b2f96d 100644 (file)
@@ -83,7 +83,7 @@ def splitfields(s, sep):
 index_error = 'substring not found in string.index'
 def index(s, 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
        raise index_error, (s, sub)
 
index 2a4feaebcc0b75aac24e3a3b276c7ccd3f9da231..3790357f1b5f50a54a8c3a5fe919c68443b2f96d 100644 (file)
@@ -83,7 +83,7 @@ def splitfields(s, sep):
 index_error = 'substring not found in string.index'
 def index(s, 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
        raise index_error, (s, sub)