summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-09-28 21:59:20 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-09-28 21:59:20 (GMT)
commitb15d4d899cbe6f54778e42eba3e827ba06fb1883 (patch)
treeaf16fecbb32900d6f0c6b78e7cf4124f8f6c7507
parentf5ca1a21a52882954de256909d13a8977d70a881 (diff)
downloadcpython-b15d4d899cbe6f54778e42eba3e827ba06fb1883.zip
cpython-b15d4d899cbe6f54778e42eba3e827ba06fb1883.tar.gz
cpython-b15d4d899cbe6f54778e42eba3e827ba06fb1883.tar.bz2
PyUnicode_CopyCharacters() marks the string as dirty (reset the hash)
-rw-r--r--Objects/unicodeobject.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index af05f4c..7a7f1d2 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -117,6 +117,9 @@ extern "C" {
(assert(PyUnicode_Check(op)), \
((PyASCIIObject *)(op))->length)
+/* The Unicode string has been modified: reset the hash */
+#define _PyUnicode_DIRTY(op) do { _PyUnicode_HASH(op) = -1; } while (0)
+
/* This dictionary holds all interned unicode strings. Note that references
to strings in this dictionary are *not* counted in the string's ob_refcnt.
@@ -356,7 +359,7 @@ unicode_resize(register PyUnicodeObject *unicode,
_PyUnicode_STATE(unicode).interned = _PyUnicode_STATE(unicode).interned;
_PyUnicode_STATE(unicode).kind = PyUnicode_WCHAR_KIND;
}
- _PyUnicode_HASH(unicode) = -1;
+ _PyUnicode_DIRTY(unicode);
return 0;
}
@@ -639,6 +642,7 @@ PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start,
"Cannot modify a string having more than 1 reference");
return -1;
}
+ _PyUnicode_DIRTY(unicode);
from_kind = PyUnicode_KIND(from);
to_kind = PyUnicode_KIND(to);