[Python-checkins] cpython: PyUnicode_CopyCharacters() marks the string as dirty (reset the hash)
victor.stinner
python-checkins at python.org
Thu Sep 29 00:01:52 CEST 2011
http://hg.python.org/cpython/rev/29ef50337bdb
changeset: 72507:29ef50337bdb
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Wed Sep 28 23:59:20 2011 +0200
summary:
PyUnicode_CopyCharacters() marks the string as dirty (reset the hash)
files:
Objects/unicodeobject.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -117,6 +117,9 @@
(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 @@
_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 @@
"Cannot modify a string having more than 1 reference");
return -1;
}
+ _PyUnicode_DIRTY(unicode);
from_kind = PyUnicode_KIND(from);
to_kind = PyUnicode_KIND(to);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list