eryksun added the comment: 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22719> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com