Exemplo n.º 1
0
def _determineClassName(x):
    c = _determineClass(x)
    try:
        return c.__name__
    except:
        try:
            return str(c)
        except:
            return '<BROKEN CLASS AT 0x%x>' % unsignedID(c)
Exemplo n.º 2
0
def _safeFormat(formatter, o):
    """
    Helper function for L{safe_repr} and L{safe_str}.
    """
    try:
        return formatter(o)
    except:
        io = StringIO()
        traceback.print_exc(file=io)
        className = _determineClassName(o)
        tbValue = io.getvalue()
        return "<%s instance at 0x%x with %s error:\n %s>" % (
            className, unsignedID(o), formatter.__name__, tbValue)
Exemplo n.º 3
0
 def __repr__(self):
     s = '<%s to %s at %x>' % (self.__class__, self.addr, unsignedID(self))
     return s
Exemplo n.º 4
0
 def __str__(self):
     cname = self.__class__.__name__
     if hasattr(self, 'result'):
         return "<%s at %s  current result: %r>" % (cname, hex(unsignedID(self)),
                                                    self.result)
     return "<%s at %s>" % (cname, hex(unsignedID(self)))