diff --git a/src/fix.py b/src/fix.py index 229049aa9..52e4f581d 100644 --- a/src/fix.py +++ b/src/fix.py @@ -127,6 +127,8 @@ def all(p, seq): return True def rsplit(s, sep=None, maxsplit=-1): + if sep is not None: + sep = sep[::-1] L = s[::-1].split(sep, maxsplit) L.reverse() return [s[::-1] for s in L] diff --git a/test/test_fix.py b/test/test_fix.py index 92fcb3e7f..e65a349ea 100644 --- a/test/test_fix.py +++ b/test/test_fix.py @@ -94,6 +94,7 @@ class FunctionsTest(unittest.TestCase): ['foo bar', 'baz']) self.assertEqual(rsplit('foo bar baz', maxsplit=1), ['foo bar', 'baz']) + self.assertEqual(rsplit('foobarbaz', 'bar'), ['foo', 'baz']) # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: