]> 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 20:05:08 +0000 (20:05 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 1 Sep 2008 20:05:08 +0000 (20:05 +0000)
a unicode argument.

Backport of r66119

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

index 69a2225cb214551a86205e65070d52aaef66766b..e56bc021bf7ae2c0fe4e25029f144297c4f42c70 100644 (file)
@@ -1066,6 +1066,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'),
@@ -1081,6 +1084,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 d2d58a5473d595118e80cf2aeb4adadda24e6171..0f005352bd917f1d2306d726353638762d5320ae 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.5.3?
 Core and builtins
 -----------------
 
+- Issue #3751: str.rpartition would perform a left-partition when called with
+  a unicode argument.
+
 - Issue #3537: Fix an assertion failure when an empty but presized dict
   object was stored in the freelist.
 
index 60d3e8ae9d8e707db2a8104a5805b89caa88aa67..85883431eefa56958ad79c3c19fbfc93d783abbb 100644 (file)
@@ -1595,7 +1595,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;