mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
Issue #17137: When an Unicode string is resized, the internal wide character
string (wstr) format is now cleared.
This commit is contained in:
parent
2efdc90b0f
commit
bbbac2ec34
3 changed files with 22 additions and 0 deletions
|
@ -702,6 +702,10 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
|
|||
if (!PyUnicode_IS_ASCII(unicode))
|
||||
_PyUnicode_WSTR_LENGTH(unicode) = length;
|
||||
}
|
||||
else if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) {
|
||||
PyObject_DEL(_PyUnicode_WSTR(unicode));
|
||||
_PyUnicode_WSTR(unicode) = NULL;
|
||||
}
|
||||
PyUnicode_WRITE(PyUnicode_KIND(unicode), PyUnicode_DATA(unicode),
|
||||
length, 0);
|
||||
assert(_PyUnicode_CheckConsistency(unicode, 0));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue