]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
(Merge 3.3) Issue #17137: When an Unicode string is resized, the internal wide
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 7 Feb 2013 22:17:34 +0000 (23:17 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 7 Feb 2013 22:17:34 +0000 (23:17 +0100)
character string (wstr) format is now cleared.

1  2 
Lib/test/test_unicode.py
Misc/NEWS
Objects/unicodeobject.c

Simple merge
diff --cc Misc/NEWS
Simple merge
index 8596e544233ee5311f2b702fe6e1f77d8ec17cc6,51160f852d292c6b051ee871d29eb2de4dff5999..4d380490607e46abe67ea278b2a64d3d2a3daa64
@@@ -717,9 -702,10 +717,13 @@@ resize_compact(PyObject *unicode, Py_ss
          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;
+     }
 +#ifdef Py_DEBUG
 +    unicode_fill_invalid(unicode, old_length);
 +#endif
      PyUnicode_WRITE(PyUnicode_KIND(unicode), PyUnicode_DATA(unicode),
                      length, 0);
      assert(_PyUnicode_CheckConsistency(unicode, 0));