[pypy-svn] rev 2672 - pypy/trunk/src/pypy/objspace/std

alex at codespeak.net alex at codespeak.net
Mon Dec 22 01:38:13 CET 2003


Author: alex
Date: Mon Dec 22 01:38:12 2003
New Revision: 2672

Modified:
   pypy/trunk/src/pypy/objspace/std/multimethod.py
   pypy/trunk/src/pypy/objspace/std/objspace.py
   pypy/trunk/src/pypy/objspace/std/typeobject.py
   pypy/trunk/src/pypy/objspace/std/usertype.py
Log:
added some __repr__ methods to ease "debugging by print-statement insertion"



Modified: pypy/trunk/src/pypy/objspace/std/multimethod.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/multimethod.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/multimethod.py	Mon Dec 22 01:38:12 2003
@@ -44,6 +44,9 @@
         self.cache_table = {}
         self.cache_delegator_key = None
 
+    def __repr__(self):
+        return '<%s %s>' % (self.__class__.__name__, self.operatorsymbol)
+
     def register(self, function, *types):
         functions = self.dispatch_table.setdefault(types, [])
         if function not in functions:
@@ -256,6 +259,7 @@
         self.extras = extras
         self.unbound_versions = {}
 
+
     def __get__(self, space, cls=object): # cls is some W_xxxType
         if issubclass(cls, self.BASE_TYPE_OBJECT):
             return self.slice(cls).get(space)

Modified: pypy/trunk/src/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/objspace.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/objspace.py	Mon Dec 22 01:38:12 2003
@@ -10,6 +10,11 @@
     def __init__(w_self, space):
         w_self.space = space     # XXX not sure this is ever used any more
 
+    def __repr__(self):
+        return '<objwrapper %s(%s)>' % (
+            self.__class__.__name__,
+            getattr(self, 'statictype', '<no statictype>')
+            )
 
 class W_AbstractTypeObject(W_Object):
     "Do not use. For W_TypeObject only."

Modified: pypy/trunk/src/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/typeobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/typeobject.py	Mon Dec 22 01:38:12 2003
@@ -19,6 +19,12 @@
         W_Object.__init__(w_self, space)
         w_self.w_tpname = space.wrap(w_self.typename)
 
+    def __repr__(self):
+        return '<typewrapper %s(%s)>' % (
+            self.__class__.__name__,
+            getattr(self, 'statictype', '<no statictype>')
+            )
+
     def getbases(w_self):
         parents = w_self.staticbases
         if parents is None:

Modified: pypy/trunk/src/pypy/objspace/std/usertype.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/usertype.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/usertype.py	Mon Dec 22 01:38:12 2003
@@ -53,6 +53,7 @@
 #   but we're documenting it here as there seems no better place!!!
 #   The problem is actually that, currently, several types such as
 #   int and float just cannot be CALLED -- this needs to be fixed soon.
+# Note: currently (03-12-21) this appears to be fully & correctly fixed.
 def type_new__UserType_UserType(space, w_basetype, w_usertype, w_args, w_kwds):
     import typetype
     # XXX this uses the following algorithm:


More information about the Pypy-commit mailing list