[pypy-svn] r5070 - pypy/trunk/src/pypy/objspace

arigo at codespeak.net arigo at codespeak.net
Sat Jun 12 14:35:04 CEST 2004


Author: arigo
Date: Sat Jun 12 14:35:03 2004
New Revision: 5070

Modified:
   pypy/trunk/src/pypy/objspace/trivial.py
Log:
Fixed the trivial object space.


Modified: pypy/trunk/src/pypy/objspace/trivial.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/trivial.py	(original)
+++ pypy/trunk/src/pypy/objspace/trivial.py	Sat Jun 12 14:35:03 2004
@@ -80,6 +80,7 @@
             __repr__ = gateway.interp2app(lambda space, w_x: repr(w_x)),
             __class__ = GetSetProperty(self.__class__.type),
             __init__ = gateway.interp2app(Object.descr__init__.im_func),
+            __dict__ = GetSetProperty(self.__class__.getdict_or_complain),
             )
         # make a wrapped None object
         none_typedef = TypeDef('NoneType',
@@ -144,6 +145,29 @@
 
     unwrap_builtin = unwrap
 
+    def getdict(self, w_obj):
+        if isinstance(w_obj, CPyWrapper):
+            obj = self.unwrap(w_obj)
+            if obj.hasdict:
+                return obj.getdict()
+            else:
+                return None
+        else:
+            try:
+                return w_obj.__dict__
+            except:
+                self.reraise()
+
+    def getdict_or_complain(self, w_obj):
+        result = self.getdict(w_obj)
+        if result is None:
+            raise OperationError(self.w_AttributeError,
+                                 self.wrap('no __dict__'))
+        return result
+
+    def allocate_instance(self, cls, w_subtype):
+        raise NotImplementedError("cannot manually instantiate built-in types")
+
     def hackwrapperclass(self, typedef):
         try:
             return typedef.trivialwrapperclass



More information about the Pypy-commit mailing list