Commits

Armin Rigo committed 7b1eec0

Add some reprs to Symbolic subclasses, and show them in the error
messages.

Comments (0)

Files changed (3)

pypy/rlib/objectmodel.py

         if self is other:
             return 0
         else:
-            raise TypeError("Symbolics can not be compared!")
+            raise TypeError("Symbolics can not be compared! (%r, %r)"
+                            % (self, other))
 
     def __hash__(self):
-        raise TypeError("Symbolics are not hashable!")
+        raise TypeError("Symbolics are not hashable! %r" % (self,))
 
     def __nonzero__(self):
-        raise TypeError("Symbolics are not comparable")
+        raise TypeError("Symbolics are not comparable! %r" % (self,))
 
 class ComputedIntSymbolic(Symbolic):
 
     def __init__(self, compute_fn):
         self.compute_fn = compute_fn
 
+    def __repr__(self):
+        return '%s(%r)' % (self.__class__.__name__, self.compute_fn)
+
     def annotation(self):
         from pypy.annotation import model
         return model.SomeInteger()
         self.expr = expr
         self.default = default
 
+    def __repr__(self):
+        return '%s(%r)' % (self.__class__.__name__, self.expr)
+
     def annotation(self):
         from pypy.annotation import model
         return model.SomeInteger()

pypy/rpython/lltypesystem/llgroup.py

         self.index = memberindex
         self.member = grp.members[memberindex]._as_ptr()
 
+    def __repr__(self):
+        return '%s(%s, %s)' % (self.__class__.__name__,
+                               self.grpptr, self.index)
+
     def __nonzero__(self):
         return True
 

pypy/rpython/lltypesystem/rffi.py

         self.c_name = c_name
         self.TP = TP
 
+    def __repr__(self):
+        return '%s(%r, %s)' % (self.__class__.__name__,
+                               self.c_name, self.TP)
+
     def annotation(self):
         return lltype_to_annotation(self.TP)