[pypy-svn] r12364 - pypy/dist/pypy/objspace/std
pedronis at codespeak.net
pedronis at codespeak.net
Mon May 16 17:11:21 CEST 2005
Author: pedronis
Date: Mon May 16 17:11:21 2005
New Revision: 12364
Modified:
pypy/dist/pypy/objspace/std/stdtypedef.py
pypy/dist/pypy/objspace/std/typeobject.py
pypy/dist/pypy/objspace/std/typetype.py
Log:
make W_TypeObject.getdict return a dict-proxy directly. Given that we have getdictvalue we will get proper behavior
from object.__getattribute__, object.__setattr__ and object.__delattr__ will fail (slightly differently) as it happens
on CPython. Notice, right now int.a = 3 still works on PyPy
Modified: pypy/dist/pypy/objspace/std/stdtypedef.py
==============================================================================
--- pypy/dist/pypy/objspace/std/stdtypedef.py (original)
+++ pypy/dist/pypy/objspace/std/stdtypedef.py Mon May 16 17:11:21 2005
@@ -8,7 +8,7 @@
__all__ = ['StdTypeDef', 'newmethod', 'gateway',
'GetSetProperty', 'Member',
- 'MultiMethod']
+ 'MultiMethod', 'descr_get_dict']
class StdTypeDef(TypeDef):
Modified: pypy/dist/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/typeobject.py (original)
+++ pypy/dist/pypy/objspace/std/typeobject.py Mon May 16 17:11:21 2005
@@ -4,6 +4,7 @@
from pypy.interpreter import gateway
from pypy.objspace.std.stdtypedef import std_dict_descr, issubtypedef, Member
from pypy.objspace.std.objecttype import object_typedef
+from pypy.objspace.std.dictproxyobject import W_DictProxyObject
from copy_reg import _HEAPTYPE
@@ -243,15 +244,14 @@
del w_self.lazyloaders
return False
- def getdict(w_self):
- # XXX should return a <dictproxy object>
+ def getdict(w_self): # returning a dict-proxy!
if w_self.lazyloaders:
w_self._freeze_() # force un-lazification
space = w_self.space
dictspec = []
for key, w_value in w_self.dict_w.items():
dictspec.append((space.wrap(key), w_value))
- return space.newdict(dictspec)
+ return W_DictProxyObject(space, space.newdict(dictspec))
def unwrap(w_self):
if hasattr(w_self.instancetypedef, 'fakedcpytype'):
Modified: pypy/dist/pypy/objspace/std/typetype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/typetype.py (original)
+++ pypy/dist/pypy/objspace/std/typetype.py Mon May 16 17:11:21 2005
@@ -1,6 +1,5 @@
from pypy.interpreter.error import OperationError
from pypy.objspace.std.stdtypedef import *
-from pypy.objspace.std.dictproxyobject import descr_get_dictproxy
def descr__new__(space, w_typetype, w_name, w_bases, w_dict):
"This is used to create user-defined classes only."
@@ -142,7 +141,7 @@
__bases__ = GetSetProperty(descr__bases),
__base__ = GetSetProperty(descr__base),
__mro__ = GetSetProperty(descr_get__mro__),
- __dict__ = GetSetProperty(descr_get_dictproxy),
+ __dict__ = GetSetProperty(descr_get_dict),
__doc__ = GetSetProperty(descr__doc),
mro = gateway.interp2app(descr_mro),
__flags__ = GetSetProperty(descr__flags),
More information about the Pypy-commit
mailing list