mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Fix endcase for str.rpartition()
This commit is contained in:
		
							parent
							
								
									bb0996ccc5
								
							
						
					
					
						commit
						a0c95fa4d8
					
				
					 5 changed files with 11 additions and 11 deletions
				
			
		| 
						 | 
					@ -771,8 +771,8 @@ The original string is returned if
 | 
				
			||||||
Split the string at the last occurrence of \var{sep}, and return
 | 
					Split the string at the last occurrence of \var{sep}, and return
 | 
				
			||||||
a 3-tuple containing the part before the separator, the separator
 | 
					a 3-tuple containing the part before the separator, the separator
 | 
				
			||||||
itself, and the part after the separator.  If the separator is not
 | 
					itself, and the part after the separator.  If the separator is not
 | 
				
			||||||
found, return a 3-tuple containing the string itself, followed by
 | 
					found, return a 3-tuple containing two empty strings, followed by
 | 
				
			||||||
two empty strings.
 | 
					the string itself.
 | 
				
			||||||
\versionadded{2.5}
 | 
					\versionadded{2.5}
 | 
				
			||||||
\end{methoddesc}
 | 
					\end{methoddesc}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1069,7 +1069,7 @@ def test_rpartition(self):
 | 
				
			||||||
        # from raymond's original specification
 | 
					        # from raymond's original specification
 | 
				
			||||||
        S = 'http://www.python.org'
 | 
					        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', '?')
 | 
				
			||||||
        self.checkequal(('', 'http://', 'www.python.org'), S, 'rpartition', 'http://')
 | 
					        self.checkequal(('', 'http://', 'www.python.org'), S, 'rpartition', 'http://')
 | 
				
			||||||
        self.checkequal(('http://www.python.', 'org', ''), S, 'rpartition', 'org')
 | 
					        self.checkequal(('http://www.python.', 'org', ''), S, 'rpartition', 'org')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,12 +78,12 @@ stringlib_rpartition(
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pos < 0) {
 | 
					    if (pos < 0) {
 | 
				
			||||||
	Py_INCREF(str_obj);
 | 
						Py_INCREF(STRINGLIB_EMPTY);
 | 
				
			||||||
	PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj);
 | 
						PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY);
 | 
				
			||||||
	Py_INCREF(STRINGLIB_EMPTY);
 | 
						Py_INCREF(STRINGLIB_EMPTY);
 | 
				
			||||||
	PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY);
 | 
						PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY);
 | 
				
			||||||
	Py_INCREF(STRINGLIB_EMPTY);
 | 
						Py_INCREF(str_obj);        
 | 
				
			||||||
	PyTuple_SET_ITEM(out, 2, (PyObject*) STRINGLIB_EMPTY);
 | 
						PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj);
 | 
				
			||||||
	return out;
 | 
						return out;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1543,11 +1543,11 @@ string_partition(PyStringObject *self, PyObject *sep_obj)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PyDoc_STRVAR(rpartition__doc__,
 | 
					PyDoc_STRVAR(rpartition__doc__,
 | 
				
			||||||
"S.rpartition(sep) -> (head, sep, tail)\n\
 | 
					"S.rpartition(sep) -> (tail, sep, head)\n\
 | 
				
			||||||
\n\
 | 
					\n\
 | 
				
			||||||
Searches for the separator sep in S, starting at the end of S, and returns\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\
 | 
					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 *
 | 
					static PyObject *
 | 
				
			||||||
string_rpartition(PyStringObject *self, PyObject *sep_obj)
 | 
					string_rpartition(PyStringObject *self, PyObject *sep_obj)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6712,11 +6712,11 @@ unicode_partition(PyUnicodeObject *self, PyObject *separator)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PyDoc_STRVAR(rpartition__doc__,
 | 
					PyDoc_STRVAR(rpartition__doc__,
 | 
				
			||||||
"S.rpartition(sep) -> (head, sep, tail)\n\
 | 
					"S.rpartition(sep) -> (tail, sep, head)\n\
 | 
				
			||||||
\n\
 | 
					\n\
 | 
				
			||||||
Searches for the separator sep in S, starting at the end of S, and returns\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\
 | 
					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*
 | 
					static PyObject*
 | 
				
			||||||
unicode_rpartition(PyUnicodeObject *self, PyObject *separator)
 | 
					unicode_rpartition(PyUnicodeObject *self, PyObject *separator)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue