This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients SilentGhost, Stéphane Henriot, ericvw, georg.brandl, martin.panter, r.david.murray, serhiy.storchaka, vstinner
Date 2016-10-25.15:24:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1477409089.34.0.118379259945.issue28029@psf.upfronthosting.co.za>
In-reply-to
Content
Interestingly, initially string.replace() was implemented in terms of split/join. string.replace(s, '', s2, n) returned s for any s, s2 and n.

After making replace() a method of str, in aca7b5eaf5e8 (1999-10-12), it became raising ValueError for empty pattern string.

Since 762dd09edb83 (issue599128, 2002-08-23) it supports zero-length pattern string. str.replace('', s1, s2, n) returned '' for any s1, s2 and n.

New implementation added in 41809406a35e (2006-05-25) made str.replace('', '', 'x', -1) returning 'x' while str.replace('', '', 'x', 1) still returns ''.

As you can see, the behavior of replacing with empty pattern is not stable. It was changed several times. Maybe it is a time for new change.
History
Date User Action Args
2016-10-25 15:24:49serhiy.storchakasetrecipients: + serhiy.storchaka, georg.brandl, vstinner, ericvw, r.david.murray, SilentGhost, martin.panter, Stéphane Henriot
2016-10-25 15:24:49serhiy.storchakasetmessageid: <1477409089.34.0.118379259945.issue28029@psf.upfronthosting.co.za>
2016-10-25 15:24:49serhiy.storchakalinkissue28029 messages
2016-10-25 15:24:49serhiy.storchakacreate