From: Guido van Rossum Date: Wed, 26 Dec 1990 15:39:06 +0000 (+0000) Subject: Fix bugf in index -- last char would not be checked. X-Git-Tag: v0.9.8~1081 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=66a07c07a5b7b1ce7150d5c5c1a0998d062e452e;p=thirdparty%2FPython%2Fcpython.git Fix bugf in index -- last char would not be checked. --- diff --git a/Lib/string.py b/Lib/string.py index 2a4feaebcc0b..3790357f1b5f 100644 --- a/Lib/string.py +++ b/Lib/string.py @@ -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) diff --git a/Lib/stringold.py b/Lib/stringold.py index 2a4feaebcc0b..3790357f1b5f 100644 --- a/Lib/stringold.py +++ b/Lib/stringold.py @@ -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)