Author v+python
Recipients SilentGhost, Stéphane Henriot, ericvw, georg.brandl, martin.panter, r.david.murray, rhettinger, serhiy.storchaka, v+python, vstinner
Date 2020-04-02.05:30:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1585805408.93.0.987889827534.issue28029@roundup.psfhosted.org>
In-reply-to
Content
Thanks Stèphańe and Serhiy, I just discovered this strange behavior in 3.8, and wondered how my logic was wrong, until I pinpointed the inconsistent behaviour of str.replace with an empty first parameter and replace count of 1.

Glad to see it is fixed in 3.9.

I guess for   x.replace( a, b, c )  the workaround would be

x.replace( a, b, c ) if a else x.replace( a, b )

At least for recent versions of Python 3.
History
Date User Action Args
2020-04-02 05:30:09v+pythonsetrecipients: + v+python, georg.brandl, rhettinger, vstinner, ericvw, r.david.murray, SilentGhost, martin.panter, serhiy.storchaka, Stéphane Henriot
2020-04-02 05:30:08v+pythonsetmessageid: <1585805408.93.0.987889827534.issue28029@roundup.psfhosted.org>
2020-04-02 05:30:08v+pythonlinkissue28029 messages
2020-04-02 05:30:08v+pythoncreate