Author: Ronan Lamy <[email protected]>
Branch: mappingproxy
Changeset: r85994:b7e537a214fd
Date: 2016-08-02 20:01 +0100
http://bitbucket.org/pypy/pypy/changeset/b7e537a214fd/

Log:    Create a real dict using the ClassDictStrategy in
        W_TypeObject.getdict()

        * DictProxyStrategy renamed to ClassDictStrategy
        * dictproxyobject.py renamed to classdict.py

        Note: in CPython, type.__dict__ returns a hidden mutable dict
        opaquely wrapped by a read-only mappingproxy object. This commit
        creates the former.

diff --git a/pypy/objspace/std/dictproxyobject.py 
b/pypy/objspace/std/classdict.py
rename from pypy/objspace/std/dictproxyobject.py
rename to pypy/objspace/std/classdict.py
--- a/pypy/objspace/std/dictproxyobject.py
+++ b/pypy/objspace/std/classdict.py
@@ -38,7 +38,7 @@
 )
 
 
-class DictProxyStrategy(DictStrategy):
+class ClassDictStrategy(DictStrategy):
     """Exposes a W_TypeObject.dict_w at app-level.
 
     Uses getdictvalue() and setdictvalue() to access items.
@@ -142,7 +142,7 @@
     # keys are utf-8 encoded identifiers from type's dict_w
     return space.wrap(key.decode('utf-8'))
 
-create_iterator_classes(DictProxyStrategy)
+create_iterator_classes(ClassDictStrategy)
 
 
 class MappingProxyStrategy(DictStrategy):
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -484,13 +484,13 @@
             del self.lazyloaders
 
     def getdict(self, space): # returning a dict-proxy!
-        from pypy.objspace.std.dictproxyobject import DictProxyStrategy
-        from pypy.objspace.std.dictproxyobject import W_DictProxyObject
+        from pypy.objspace.std.classdict import ClassDictStrategy
+        from pypy.objspace.std.dictmultiobject import W_DictObject
         if self.lazyloaders:
             self._cleanup_()    # force un-lazification
-        strategy = space.fromcache(DictProxyStrategy)
+        strategy = space.fromcache(ClassDictStrategy)
         storage = strategy.erase(self)
-        return W_DictProxyObject(space, strategy, storage)
+        return W_DictObject(space, strategy, storage)
 
     def is_heaptype(self):
         return self.flag_heaptype
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to