summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1990-12-26 15:39:06 (GMT)
committerGuido van Rossum <guido@python.org>1990-12-26 15:39:06 (GMT)
commit66a07c07a5b7b1ce7150d5c5c1a0998d062e452e (patch)
tree624b5069e9a5f2d7ee35e857b83532f525d5be95 /Lib
parenta4ddbd885e7654da03881feb6e588006f024653e (diff)
downloadcpython-66a07c07a5b7b1ce7150d5c5c1a0998d062e452e.zip
cpython-66a07c07a5b7b1ce7150d5c5c1a0998d062e452e.tar.gz
cpython-66a07c07a5b7b1ce7150d5c5c1a0998d062e452e.tar.bz2
Fix bugf in index -- last char would not be checked.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/string.py2
-rw-r--r--Lib/stringold.py2
2 files changed, 2 insertions, 2 deletions
diff --git a/Lib/string.py b/Lib/string.py
index 2a4feae..3790357 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 2a4feae..3790357 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)