]> granicus.if.org Git - python/commitdiff
Issue #3751: str.rpartition would perform a left-partition when called with
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 1 Sep 2008 19:52:00 +0000 (19:52 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 1 Sep 2008 19:52:00 +0000 (19:52 +0000)
a unicode argument.

will backport.

Lib/test/string_tests.py
Misc/NEWS
Objects/stringobject.c

index 3590b8e5b9ad427c1226ef03e214b1c8619511a7..63279ec363612c878902b176f41259d071910e8b 100644 (file)
@@ -1117,6 +1117,9 @@ class MixinStrUnicodeUserStringTest:
         self.checkraises(ValueError, S, 'partition', '')
         self.checkraises(TypeError, S, 'partition', None)
 
+        # mixed use of str and unicode
+        self.assertEqual('a/b/c'.partition(u'/'), ('a', '/', 'b/c'))
+
     def test_rpartition(self):
 
         self.checkequal(('this is the rparti', 'ti', 'on method'),
@@ -1132,6 +1135,8 @@ class MixinStrUnicodeUserStringTest:
         self.checkraises(ValueError, S, 'rpartition', '')
         self.checkraises(TypeError, S, 'rpartition', None)
 
+        # mixed use of str and unicode
+        self.assertEqual('a/b/c'.rpartition(u'/'), ('a/b', '/', 'c'))
 
 class MixinStrStringUserStringTest:
     # Additional tests for 8bit strings, i.e. str, UserString and
index d8145c37de9d55745ff7a5a6d02d9bffddbb3e57..6f012ab94da7bde8c0da790c492f67e4898429dd 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.6 release candidate 1?
 Core and Builtins
 -----------------
 
+- Issue #3751: str.rpartition would perform a left-partition when called with
+  a unicode argument.
+
 - Issue #3683: Fix compilation when --without-threads is given.
 
 - Issue #3668: Fix a memory leak with the "s*" argument parser in
index 5bf4add229c692cadc5a4a99cf5f40620a0d078e..b9a70a0c086af60803e56f2f01bb7921f44a2101 100644 (file)
@@ -1638,7 +1638,7 @@ string_rpartition(PyStringObject *self, PyObject *sep_obj)
        }
 #ifdef Py_USING_UNICODE
        else if (PyUnicode_Check(sep_obj))
-               return PyUnicode_Partition((PyObject *) self, sep_obj);
+               return PyUnicode_RPartition((PyObject *) self, sep_obj);
 #endif
        else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len))
                return NULL;