]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix unicode.rsplit()'s bug that ignores separater on the end of string when
authorHye-Shik Chang <hyeshik@gmail.com>
Tue, 23 Dec 2003 09:10:16 +0000 (09:10 +0000)
committerHye-Shik Chang <hyeshik@gmail.com>
Tue, 23 Dec 2003 09:10:16 +0000 (09:10 +0000)
using specialized splitter for 1 char sep.

Lib/test/string_tests.py
Objects/unicodeobject.c

index c3e53ad48b9aa5e14902bd8bb60152443c9f8c80..eafc89a294d516809b43f401287ebd221e415583 100644 (file)
@@ -208,6 +208,8 @@ class CommonTest(unittest.TestCase):
         self.checkequal(['a\x00b', 'c'], 'a\x00b\x00c', 'rsplit', '\x00', 1)
         self.checkequal(['', ''], 'abcd', 'rsplit', 'abcd')
         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):
         self.checkequal('hello', '   hello   ', 'strip')
index b3c4a01e2f4e282fdd0b247708c090b86391012c..636dfcc0c706845c2a686ba3ce7e220914a267f5 100644 (file)
@@ -4294,7 +4294,7 @@ PyObject *rsplit_char(PyUnicodeObject *self,
        } else
            i--;
     }
-    if (j >= 0) {
+    if (j >= -1) {
        SPLIT_INSERT(self->str, 0, j + 1);
     }
     return list;