[Python-checkins] cpython: Fix resize_inplace(): update shared utf8 pointer

victor.stinner python-checkins at python.org
Mon Oct 3 12:21:41 CEST 2011


http://hg.python.org/cpython/rev/f96d8f8a6e37
changeset:   72609:f96d8f8a6e37
user:        Victor Stinner <vstinner at wyplay.com>
date:        Mon Oct 03 12:11:00 2011 +0200
summary:
  Fix resize_inplace(): update shared utf8 pointer

files:
  Objects/unicodeobject.c |  5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -443,13 +443,14 @@
     if (PyUnicode_IS_READY(unicode)) {
         Py_ssize_t char_size;
         Py_ssize_t new_size;
-        int share_wstr;
+        int share_wstr, share_utf8;
         void *data;
 
         data = _PyUnicode_DATA_ANY(unicode);
         assert(data != NULL);
         char_size = PyUnicode_CHARACTER_SIZE(unicode);
         share_wstr = (_PyUnicode_WSTR(unicode) == data);
+        share_utf8 = (_PyUnicode_UTF8(unicode) == data);
 
         if (length > (PY_SSIZE_T_MAX / char_size - 1)) {
             PyErr_NoMemory();
@@ -465,6 +466,8 @@
         _PyUnicode_DATA_ANY(unicode) = data;
         if (share_wstr)
             _PyUnicode_WSTR(unicode) = data;
+        if (share_utf8)
+            _PyUnicode_UTF8(unicode) = data;
         _PyUnicode_LENGTH(unicode) = length;
         PyUnicode_WRITE(PyUnicode_KIND(unicode), data, length, 0);
         if (share_wstr)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list