summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-09-01 20:05:08 +0000
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-09-01 20:05:08 +0000
commitafa0d58a2d55fa157482e2006028688db6553f90 (patch)
treeec5c92dab493ce55e8fcd2099428b5089387127e
parent50b1c4920be53f5155fce046617bb700fd02574f (diff)
downloadcpython-git-afa0d58a2d55fa157482e2006028688db6553f90.tar.gz
Issue #3751: str.rpartition would perform a left-partition when called with
a unicode argument. Backport of r66119
-rw-r--r--Lib/test/string_tests.py5
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/stringobject.c2
3 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index 69a2225cb2..e56bc021bf 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -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
diff --git a/Misc/NEWS b/Misc/NEWS
index d2d58a5473..0f005352bd 100644
--- 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.
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 60d3e8ae9d..85883431ee 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -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;