• Andrew Dalke's avatar
    Fixed problem identified by Georg. The special-case in-place code for replace · 8c909107
    Andrew Dalke authored
    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?
    8c909107
stringobject.c 116 KB