]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
The strop module and test_strop.py believe replace() with a 0 count
authorTim Peters <tim.peters@gmail.com>
Thu, 10 May 2001 00:59:45 +0000 (00:59 +0000)
committerTim Peters <tim.peters@gmail.com>
Thu, 10 May 2001 00:59:45 +0000 (00:59 +0000)
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.

Lib/test/test_strop.py
Modules/stropmodule.c

index 57700460da3b1d6bbe702c8bf307e9433b960f14..de7a7959ff6329d1d908c3dcc26643578d42988e 100644 (file)
@@ -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@', '!', '@', 3)
 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!', 'x', '@')
 test('replace', 'one!two!three!', 'one!two!three!', 'x', '@', 2)
index c2457949a29e18d6432ea35da14ae3c6272509e6..aa9cdc76a052820738526277c4062e9b0377e582 100644 (file)
@@ -1121,7 +1121,7 @@ strop_replace(PyObject *self, PyObject *args)
 {
        char *str, *pat,*sub,*new_s;
        int len,pat_len,sub_len,out_len;
-       int count = 0;
+       int count = -1;
        PyObject *new;
 
        if (!PyArg_ParseTuple(args, "t#t#t#|i:replace",