def getitem(self, w_dict, w_key): space = self.space w_lookup_type = space.type(w_key) if space.is_w(w_lookup_type, space.w_str): return self.getitem_str(w_dict, space.str_w(w_key)) elif _never_equal_to_string(space, w_lookup_type): return None else: self.switch_to_object_strategy(w_dict) return w_dict.getitem(w_key)
def getitem(self, w_dict, w_key): space = self.space w_lookup_type = space.type(w_key) key = self.try_unwrap_key(space, w_key) if key is not None: return self.getitem_str(w_dict, key) elif _never_equal_to_string(space, w_lookup_type): return None else: self.switch_to_object_strategy(w_dict) return w_dict.getitem(w_key)
def delitem(self, w_dict, w_key): space = self.space w_key_type = space.type(w_key) w_obj = self.unerase(w_dict.dstorage) if space.is_w(w_key_type, space.w_str): key = self.space.str_w(w_key) flag = w_obj.deldictvalue(space, key) if not flag: raise KeyError elif _never_equal_to_string(space, w_key_type): raise KeyError else: self.switch_to_object_strategy(w_dict) w_dict.delitem(w_key)
def delitem(self, w_dict, w_key): space = self.space w_key_type = space.type(w_key) if space.is_w(w_key_type, space.w_str): key = space.str_w(w_key) dict_w = self.unerase(w_dict.dstorage) try: del dict_w[key] except KeyError: raise else: self.mutated() elif _never_equal_to_string(space, w_key_type): raise KeyError else: self.switch_to_object_strategy(w_dict) w_dict.delitem(w_key)
def delitem(self, w_dict, w_key): space = self.space w_key_type = space.type(w_key) key = self.try_unwrap_key(space, w_key) if key is not None: dict_w = self.unerase(w_dict.dstorage) try: del dict_w[key] except KeyError: raise else: self.mutated() elif _never_equal_to_string(space, w_key_type): raise KeyError else: self.switch_to_object_strategy(w_dict) w_dict.delitem(w_key)
def delitem(self, w_dict, w_key): space = self.space w_key_type = space.type(w_key) if space.is_w(w_key_type, space.w_text): key = space.text_w(w_key) dict_w = self.unerase(w_dict.dstorage) try: del dict_w[key] except KeyError: raise else: if self.caches: cache = self.caches.get(key, None) if cache: cache.cell = None self.mutated() elif _never_equal_to_string(space, w_key_type): raise KeyError else: self.switch_to_object_strategy(w_dict) w_dict.delitem(w_key)