Ejemplo n.º 1
0
 def getdict(w_self, space):  # returning a dict-proxy!
     from pypy.objspace.std.dictproxyobject import DictProxyStrategy
     from pypy.objspace.std.dictmultiobject import W_DictMultiObject
     if w_self.lazyloaders:
         w_self._cleanup_()  # force un-lazification
     strategy = space.fromcache(DictProxyStrategy)
     storage = strategy.erase(w_self)
     return W_DictMultiObject(space, strategy, storage)
Ejemplo n.º 2
0
    def getdict(self, space):
        w_dict = self._get_mapdict_map().read(self, ("dict", SPECIAL))
        if w_dict is not None:
            assert isinstance(w_dict, W_DictMultiObject)
            return w_dict

        strategy = space.fromcache(MapDictStrategy)
        storage = strategy.erase(self)
        w_dict = W_DictMultiObject(space, strategy, storage)
        flag = self._get_mapdict_map().write(self, ("dict", SPECIAL), w_dict)
        assert flag
        return w_dict
Ejemplo n.º 3
0
    def test_same_key_set_twice(self):
        strategy = ModuleDictStrategy(space)
        storage = strategy.get_empty_storage()
        d = W_DictMultiObject(space, strategy, storage)

        v1 = strategy.version
        x = object()
        d.setitem(u"a", x)
        v2 = strategy.version
        assert v1 is not v2
        d.setitem(u"a", x)
        v3 = strategy.version
        assert v2 is v3
Ejemplo n.º 4
0
 def newdict(self, track_builtin_shadowing=False):
     if self.config.objspace.opcodes.CALL_LIKELY_BUILTIN and track_builtin_shadowing:
         from pypy.objspace.std.dictmultiobject import W_DictMultiObject
         return W_DictMultiObject(self, wary=True)
     return self.DictObjectCls(self)
Ejemplo n.º 5
0
 def newdict(self, module=False):
     from pypy.objspace.std.dictmultiobject import W_DictMultiObject
     if module:
         return W_DictMultiObject(self, module=True)
     return W_DictMultiObject(self)
Ejemplo n.º 6
0
 def setup_method(self, method):
     space = self.space
     strategy = ModuleDictStrategy(space)
     storage = strategy.get_empty_storage()
     self.w_d = W_DictMultiObject(space, strategy, storage)
Ejemplo n.º 7
0
 def setup_class(cls):
     if cls.runappdirect:
         py.test.skip("__repr__ doesn't work on appdirect")
     strategy = ModuleDictStrategy(cls.space)
     storage = strategy.get_empty_storage()
     cls.w_d = W_DictMultiObject(cls.space, strategy, storage)