[Python-checkins] r51704 - in python/trunk: Doc/lib/libstdtypes.tex Lib/test/string_tests.py Objects/stringlib/partition.h Objects/stringobject.c Objects/unicodeobject.c

raymond.hettinger python-checkins at python.org
Mon Sep 4 17:32:50 CEST 2006


Author: raymond.hettinger
Date: Mon Sep  4 17:32:48 2006
New Revision: 51704

Modified:
   python/trunk/Doc/lib/libstdtypes.tex
   python/trunk/Lib/test/string_tests.py
   python/trunk/Objects/stringlib/partition.h
   python/trunk/Objects/stringobject.c
   python/trunk/Objects/unicodeobject.c
Log:
Fix endcase for str.rpartition()

Modified: python/trunk/Doc/lib/libstdtypes.tex
==============================================================================
--- python/trunk/Doc/lib/libstdtypes.tex	(original)
+++ python/trunk/Doc/lib/libstdtypes.tex	Mon Sep  4 17:32:48 2006
@@ -771,8 +771,8 @@
 Split the string at the last occurrence of \var{sep}, and return
 a 3-tuple containing the part before the separator, the separator
 itself, and the part after the separator.  If the separator is not
-found, return a 3-tuple containing the string itself, followed by
-two empty strings.
+found, return a 3-tuple containing two empty strings, followed by
+the string itself.
 \versionadded{2.5}
 \end{methoddesc}
 

Modified: python/trunk/Lib/test/string_tests.py
==============================================================================
--- python/trunk/Lib/test/string_tests.py	(original)
+++ python/trunk/Lib/test/string_tests.py	Mon Sep  4 17:32:48 2006
@@ -1069,7 +1069,7 @@
         # from raymond's original specification
         S = 'http://www.python.org'
         self.checkequal(('http', '://', 'www.python.org'), S, 'rpartition', '://')
-        self.checkequal(('http://www.python.org', '', ''), S, 'rpartition', '?')
+        self.checkequal(('', '', 'http://www.python.org'), S, 'rpartition', '?')
         self.checkequal(('', 'http://', 'www.python.org'), S, 'rpartition', 'http://')
         self.checkequal(('http://www.python.', 'org', ''), S, 'rpartition', 'org')
 

Modified: python/trunk/Objects/stringlib/partition.h
==============================================================================
--- python/trunk/Objects/stringlib/partition.h	(original)
+++ python/trunk/Objects/stringlib/partition.h	Mon Sep  4 17:32:48 2006
@@ -78,12 +78,12 @@
             }
 
     if (pos < 0) {
-	Py_INCREF(str_obj);
-	PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj);
 	Py_INCREF(STRINGLIB_EMPTY);
-	PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY);
+	PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY);
 	Py_INCREF(STRINGLIB_EMPTY);
-	PyTuple_SET_ITEM(out, 2, (PyObject*) STRINGLIB_EMPTY);
+	PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY);
+	Py_INCREF(str_obj);        
+	PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj);
 	return out;
     }
 

Modified: python/trunk/Objects/stringobject.c
==============================================================================
--- python/trunk/Objects/stringobject.c	(original)
+++ python/trunk/Objects/stringobject.c	Mon Sep  4 17:32:48 2006
@@ -1543,11 +1543,11 @@
 }
 
 PyDoc_STRVAR(rpartition__doc__,
-"S.rpartition(sep) -> (head, sep, tail)\n\
+"S.rpartition(sep) -> (tail, sep, head)\n\
 \n\
 Searches for the separator sep in S, starting at the end of S, and returns\n\
 the part before it, the separator itself, and the part after it.  If the\n\
-separator is not found, returns S and two empty strings.");
+separator is not found, returns two empty strings and S.");
 
 static PyObject *
 string_rpartition(PyStringObject *self, PyObject *sep_obj)

Modified: python/trunk/Objects/unicodeobject.c
==============================================================================
--- python/trunk/Objects/unicodeobject.c	(original)
+++ python/trunk/Objects/unicodeobject.c	Mon Sep  4 17:32:48 2006
@@ -6712,11 +6712,11 @@
 }
 
 PyDoc_STRVAR(rpartition__doc__,
-"S.rpartition(sep) -> (head, sep, tail)\n\
+"S.rpartition(sep) -> (tail, sep, head)\n\
 \n\
 Searches for the separator sep in S, starting at the end of S, and returns\n\
 the part before it, the separator itself, and the part after it.  If the\n\
-separator is not found, returns S and two empty strings.");
+separator is not found, returns two empty strings and S.");
 
 static PyObject*
 unicode_rpartition(PyUnicodeObject *self, PyObject *separator)


More information about the Python-checkins mailing list