Glenn Linderman <v+pyt...@g.nevcal.com> added the comment:

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.

----------
nosy: +v+python

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue28029>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to