summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-08-19 16:49:58 (GMT)
committerGuido van Rossum <guido@python.org>1992-08-19 16:49:58 (GMT)
commitae507a42a0425f2397a5f7b3163dc0c1d6d0aaef (patch)
treeb5b1b7e847b044e4284bb408056f5610d5ee7ae9
parent732282fa1130a027a51d406ed5132cde9ac636e7 (diff)
downloadcpython-ae507a42a0425f2397a5f7b3163dc0c1d6d0aaef.zip
cpython-ae507a42a0425f2397a5f7b3163dc0c1d6d0aaef.tar.gz
cpython-ae507a42a0425f2397a5f7b3163dc0c1d6d0aaef.tar.bz2
splitfields(s, '') is illegal
-rw-r--r--Lib/string.py6
-rw-r--r--Lib/stringold.py6
2 files changed, 10 insertions, 2 deletions
diff --git a/Lib/string.py b/Lib/string.py
index 94e9157..f358ac4 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -63,10 +63,14 @@ def split(s):
# Split a list into fields separated by a given string
# NB: splitfields(s, ' ') is NOT the same as split(s)!
+# splitfields(s, '') is illegal
+splitfields_error = 'string.splitfields called with empty separator'
def splitfields(s, sep):
res = []
- ns = len(s)
nsep = len(sep)
+ if nsep == 0:
+ raise splitfields_error
+ ns = len(s)
i = j = 0
while j+nsep <= ns:
if s[j:j+nsep] == sep:
diff --git a/Lib/stringold.py b/Lib/stringold.py
index 94e9157..f358ac4 100644
--- a/Lib/stringold.py
+++ b/Lib/stringold.py
@@ -63,10 +63,14 @@ def split(s):
# Split a list into fields separated by a given string
# NB: splitfields(s, ' ') is NOT the same as split(s)!
+# splitfields(s, '') is illegal
+splitfields_error = 'string.splitfields called with empty separator'
def splitfields(s, sep):
res = []
- ns = len(s)
nsep = len(sep)
+ if nsep == 0:
+ raise splitfields_error
+ ns = len(s)
i = j = 0
while j+nsep <= ns:
if s[j:j+nsep] == sep: