mirror of
https://github.com/python/cpython.git
synced 2025-09-11 19:27:07 +00:00
The strop module and test_strop.py believe replace() with a 0 count
means "replace everything". But the string module, string.replace() amd test_string.py believe a 0 count means "replace nothing". "Nothing" wins, strop loses. Bugfix candidate.
This commit is contained in:
parent
9c012af3c3
commit
da45d55a6e
2 changed files with 2 additions and 2 deletions
|
@ -77,7 +77,7 @@ test('replace', 'one!two!three!', 'one@two!three!', '!', '@', 1)
|
||||||
test('replace', 'one!two!three!', 'one@two@three!', '!', '@', 2)
|
test('replace', 'one!two!three!', 'one@two@three!', '!', '@', 2)
|
||||||
test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 3)
|
test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 3)
|
||||||
test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 4)
|
test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 4)
|
||||||
test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 0)
|
test('replace', 'one!two!three!', 'one!two!three!', '!', '@', 0)
|
||||||
test('replace', 'one!two!three!', 'one@two@three@', '!', '@')
|
test('replace', 'one!two!three!', 'one@two@three@', '!', '@')
|
||||||
test('replace', 'one!two!three!', 'one!two!three!', 'x', '@')
|
test('replace', 'one!two!three!', 'one!two!three!', 'x', '@')
|
||||||
test('replace', 'one!two!three!', 'one!two!three!', 'x', '@', 2)
|
test('replace', 'one!two!three!', 'one!two!three!', 'x', '@', 2)
|
||||||
|
|
|
@ -1121,7 +1121,7 @@ strop_replace(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
char *str, *pat,*sub,*new_s;
|
char *str, *pat,*sub,*new_s;
|
||||||
int len,pat_len,sub_len,out_len;
|
int len,pat_len,sub_len,out_len;
|
||||||
int count = 0;
|
int count = -1;
|
||||||
PyObject *new;
|
PyObject *new;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "t#t#t#|i:replace",
|
if (!PyArg_ParseTuple(args, "t#t#t#|i:replace",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue