From 93be92d30925d2e2d387987e418b083f8bb6e26e Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Tue, 2 Dec 1997 00:29:30 +0000 Subject: [PATCH] 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. --- Modules/stropmodule.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c index 9fc4b9b281d..6de624e7094 100644 --- a/Modules/stropmodule.c +++ b/Modules/stropmodule.c @@ -85,7 +85,10 @@ split_whitespace(s, len, maxsplit) goto finally; countsplit++; - if (maxsplit && (countsplit >= maxsplit)) { + while (i < len && isspace(Py_CHARMASK(s[i]))) { + i = i+1; + } + if (maxsplit && (countsplit >= maxsplit) && i < len) { item = PyString_FromStringAndSize( s+i, (int)(len - i)); if (item == NULL)