summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHye-Shik Chang <hyeshik@gmail.com>2003-12-23 09:10:16 (GMT)
committerHye-Shik Chang <hyeshik@gmail.com>2003-12-23 09:10:16 (GMT)
commit7fc4cf57b8f75784e269e64403a1ea2b08bd512b (patch)
tree9ca8cc22a68905af3d194fcf0e6659fdb2be0c99
parent0490fe96d882072aca640ef5c6f42ed80a789f0d (diff)
downloadcpython-7fc4cf57b8f75784e269e64403a1ea2b08bd512b.zip
cpython-7fc4cf57b8f75784e269e64403a1ea2b08bd512b.tar.gz
cpython-7fc4cf57b8f75784e269e64403a1ea2b08bd512b.tar.bz2
Fix unicode.rsplit()'s bug that ignores separater on the end of string when
using specialized splitter for 1 char sep.
-rw-r--r--Lib/test/string_tests.py2
-rw-r--r--Objects/unicodeobject.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index c3e53ad..eafc89a 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -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')
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index b3c4a01..636dfcc 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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;