Mercurial > cpython-lru_cache-weakref
diff Objects/unicodeobject.c @ 72507:29ef50337bdb
PyUnicode_CopyCharacters() marks the string as dirty (reset the hash)
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Wed, 28 Sep 2011 23:59:20 +0200 |
| parents | 9f0e1f44ebac |
| children | 8d4252f0bf14 |
line wrap: on
line diff
--- a/Objects/unicodeobject.c Wed Sep 28 23:54:59 2011 +0200 +++ b/Objects/unicodeobject.c Wed Sep 28 23:59:20 2011 +0200 @@ -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);
