mirror of https://github.com/python/cpython.git
splitfields(s, '') is illegal
This commit is contained in:
parent
732282fa11
commit
ae507a42a0
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue