[Python-checkins] r66121 - in python/branches/release25-maint: Lib/test/string_tests.py Misc/NEWS Objects/stringobject.c

amaury.forgeotdarc python-checkins at python.org
Mon Sep 1 22:05:09 CEST 2008


Author: amaury.forgeotdarc
Date: Mon Sep  1 22:05:08 2008
New Revision: 66121

Log:
Issue #3751: str.rpartition would perform a left-partition when called with
a unicode argument.

Backport of r66119


Modified:
   python/branches/release25-maint/Lib/test/string_tests.py
   python/branches/release25-maint/Misc/NEWS
   python/branches/release25-maint/Objects/stringobject.c

Modified: python/branches/release25-maint/Lib/test/string_tests.py
==============================================================================
--- python/branches/release25-maint/Lib/test/string_tests.py	(original)
+++ python/branches/release25-maint/Lib/test/string_tests.py	Mon Sep  1 22:05:08 2008
@@ -1066,6 +1066,9 @@
         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 @@
         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

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Mon Sep  1 22:05:08 2008
@@ -12,6 +12,9 @@
 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.
 

Modified: python/branches/release25-maint/Objects/stringobject.c
==============================================================================
--- python/branches/release25-maint/Objects/stringobject.c	(original)
+++ python/branches/release25-maint/Objects/stringobject.c	Mon Sep  1 22:05:08 2008
@@ -1595,7 +1595,7 @@
 	}
 #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;


More information about the Python-checkins mailing list