Commit 7fc4cf57 authored by Hye-Shik Chang's avatar Hye-Shik Chang

Fix unicode.rsplit()'s bug that ignores separater on the end of string when

using specialized splitter for 1 char sep.
parent 0490fe96
...@@ -208,6 +208,8 @@ class CommonTest(unittest.TestCase): ...@@ -208,6 +208,8 @@ class CommonTest(unittest.TestCase):
self.checkequal(['a\x00b', 'c'], 'a\x00b\x00c', 'rsplit', '\x00', 1) self.checkequal(['a\x00b', 'c'], 'a\x00b\x00c', 'rsplit', '\x00', 1)
self.checkequal(['', ''], 'abcd', 'rsplit', 'abcd') self.checkequal(['', ''], 'abcd', 'rsplit', 'abcd')
self.checkequal([u'a b', u'c', u'd'], 'a b c d', 'rsplit', u' ', 2) self.checkequal([u'a b', u'c', u'd'], 'a b c d', 'rsplit', u' ', 2)
self.checkequal(['', ' endcase'], '| endcase', 'rsplit', '|')
self.checkequal(['', ' endcase'], 'test endcase', 'rsplit', 'test')
def test_strip(self): def test_strip(self):
self.checkequal('hello', ' hello ', 'strip') self.checkequal('hello', ' hello ', 'strip')
......
...@@ -4294,7 +4294,7 @@ PyObject *rsplit_char(PyUnicodeObject *self, ...@@ -4294,7 +4294,7 @@ PyObject *rsplit_char(PyUnicodeObject *self,
} else } else
i--; i--;
} }
if (j >= 0) { if (j >= -1) {
SPLIT_INSERT(self->str, 0, j + 1); SPLIT_INSERT(self->str, 0, j + 1);
} }
return list; return list;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment