[Python-Dev] Inconsistent string.replace() behavior

Tim Peters tim.one@home.com
Wed, 9 May 2001 20:47:52 -0400


test_strop.py contains this line:

    test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 0)

string_tests.py has this:

    test('replace', 'one!two!three!', 'one!two!three!', '!', '@', 0)

IOW, the test suite insists that

    strop.replace('one!two!three!', '!', '@', 0)

replace all matches but that

    string.replace('one!two!three!', '!', '@', 0)
and
    'one!two!three!'.replace('!', '@', 0)

replace nothing.

I've been thrashing like a madman trying to fix a common bug in both modules
(in out-of-synch copies of mymemreplace), and every time I think I fix
something "the other" module breaks.  The above appears to be why.

My opinion:  the test_strop.py test is in error, and so was strop_replace()
in stropmodule.c.  I'm checking in changes accordingly, but won't mind
getting yelled at if you disagree.