From bc72b26c4febeddea6e97909224b7d24e9415085 Mon Sep 17 00:00:00 2001 From: Stephen Kappel Date: Wed, 18 Mar 2015 15:22:58 -0400 Subject: [PATCH] Fix __delitem__ to remove reference from given key Previously, the __delitem__ method deleted the value and references from other keys, but did not remove the reference from the given key. This would cause the has_key method to incorrectly indicate that the key was present - even after it had been deleted. --- multi_key_dict.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/multi_key_dict.py b/multi_key_dict.py index aea99b0..543c165 100644 --- a/multi_key_dict.py +++ b/multi_key_dict.py @@ -151,6 +151,10 @@ class multi_key_dict(object): key_type = str(type(k)) if (key_type in self.__dict__ and k in self.__dict__[key_type]): del self.__dict__[key_type][k] + + # remove the reference from the given key + del self.__dict__[key_type][key] + else: raise KeyError(key)