From 53b977127fe8192f8bdf6a400de81086e128e936 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Mon, 23 Apr 2012 11:50:47 -0400 Subject: [PATCH] don't make shared keys with dict subclasses --- Objects/dictobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 2e45c8d8fdd..2afbbaee503 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -3686,7 +3686,7 @@ _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, 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;