[Python-checkins] cpython: don't make shared keys with dict subclasses

benjamin.peterson python-checkins at python.org
Mon Apr 23 17:50:52 CEST 2012


http://hg.python.org/cpython/rev/e3ea9e975689
changeset:   76489:e3ea9e975689
user:        Benjamin Peterson <benjamin at python.org>
date:        Mon Apr 23 11:50:47 2012 -0400
summary:
  don't make shared keys with dict subclasses

files:
  Objects/dictobject.c |  2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Objects/dictobject.c b/Objects/dictobject.c
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -3686,7 +3686,7 @@
             res = PyDict_SetItem(dict, key, value);
             if (cached != ((PyDictObject *)dict)->ma_keys) {
                 /* Either update tp->ht_cached_keys or delete it */
-                if (cached->dk_refcnt == 1) {
+                if (cached->dk_refcnt == 1 && PyDict_CheckExact(dict)) {
                     CACHED_KEYS(tp) = make_keys_shared(dict);
                     if (CACHED_KEYS(tp) == NULL)
                         return -1;

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


More information about the Python-checkins mailing list