def setdict(self, space, w_dict): # if somebody asked for the __dict__, and it did not devolve, it # needs to stay valid even if we set a new __dict__ on this object if self.w__dict__ is not None and self._inlined_dict_valid(): make_rdict(self) self._clear_fields() # invalidate attributes on self self.w__dict__ = check_new_dictionary(space, w_dict)
def setdict(self, space, w_dict): from pypy.interpreter.typedef import check_new_dictionary w_dict = check_new_dictionary(space, w_dict) w_olddict = self.getdict(space) assert isinstance(w_dict, W_DictMultiObject) if type(w_olddict.strategy) is not ObjectDictStrategy: w_olddict.strategy.switch_to_object_strategy(w_olddict) flag = self._get_mapdict_map().write(self, ("dict", SPECIAL), w_dict) assert flag
def setdict(self, space, w_dict): from pypy.interpreter.typedef import check_new_dictionary w_dict = check_new_dictionary(space, w_dict) w_olddict = self.getdict(space) assert isinstance(w_dict, W_DictMultiObject) # The old dict has got 'self' as dstorage, but we are about to # change self's ("dict", SPECIAL) attribute to point to the # new dict. If the old dict was using the MapDictStrategy, we # have to force it now: otherwise it would remain an empty # shell that continues to delegate to 'self'. if type(w_olddict.get_strategy()) is MapDictStrategy: w_olddict.get_strategy().switch_to_object_strategy(w_olddict) flag = self._get_mapdict_map().write(self, "dict", SPECIAL, w_dict) assert flag