Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93be92d

Browse files
committed
split_whitespace(): Make sure delimiter is stripped from the beginning
of the remainder item (last item in list) when maxsplit is < the number of occurrences.
1 parent 8529ebb commit 93be92d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Modules/stropmodule.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ split_whitespace(s, len, maxsplit)
8585
goto finally;
8686

8787
countsplit++;
88-
if (maxsplit && (countsplit >= maxsplit)) {
88+
while (i < len && isspace(Py_CHARMASK(s[i]))) {
89+
i = i+1;
90+
}
91+
if (maxsplit && (countsplit >= maxsplit) && i < len) {
8992
item = PyString_FromStringAndSize(
9093
s+i, (int)(len - i));
9194
if (item == NULL)

0 commit comments

Comments
 (0)