Author eryksun
Recipients eryksun, hosford42, r.david.murray, serhiy.storchaka, steve.dower, tim.golden, zach.ware
Date 2014-10-24.21:46:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1414187202.6.0.535022953689.issue22719@psf.upfronthosting.co.za>
In-reply-to
Content
When appending to a singly-referenced string, the interpreter tries to reallocate the string in place. This applies to both `s += 'text'` and `s = s + 'text'`. Storing to a temp variable is adding a 2nd reference, so a new string gets allocated instead. If the former is the case (i.e. the object id is the same after appending), use ctypes to check the string's cached wide-string (wchar_t *) representation:

    from ctypes import *
                                             
    pythonapi.PyUnicode_AsUnicode.argtypes = [py_object]
    pythonapi.PyUnicode_AsUnicode.restype = c_wchar_p

    print(pythonapi.PyUnicode_AsUnicode(bak_path))

The wstr cache should be cleared when the string is reallocated in place, so this is probably a dead end.
History
Date User Action Args
2014-10-24 21:46:42eryksunsetrecipients: + eryksun, tim.golden, r.david.murray, zach.ware, serhiy.storchaka, steve.dower, hosford42
2014-10-24 21:46:42eryksunsetmessageid: <1414187202.6.0.535022953689.issue22719@psf.upfronthosting.co.za>
2014-10-24 21:46:42eryksunlinkissue22719 messages
2014-10-24 21:46:42eryksuncreate