]> granicus.if.org Git - python/commit
Fixed problem identified by Georg. The special-case in-place code for replace
authorAndrew Dalke <dalke@dalkescientific.com>
Thu, 25 May 2006 17:53:00 +0000 (17:53 +0000)
committerAndrew Dalke <dalke@dalkescientific.com>
Thu, 25 May 2006 17:53:00 +0000 (17:53 +0000)
commit8c9091074b6a0e7e48eb2cce03a4eb193cb993be
tree00401c251222ba1b77739198ccf1d583fca17285
parentda53afa1b09218c0fb7ce8803cd783a43ee9d319
Fixed problem identified by Georg.  The special-case in-place code for replace
made a copy of the string using PyString_FromStringAndSize(s, n) and modify
the copied string in-place.  However, 1 (and 0) character strings are shared
from a cache.  This cause "A".replace("A", "a") to change the cached version
of "A" -- used by everyone.

Now may the copy with NULL as the string and do the memcpy manually.  I've
added regression tests to check if this happens in the future.  Perhaps
there should be a PyString_Copy for this case?
Objects/stringobject.c