示例#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)
示例#2
0
文件: _reflect.py 项目: jml/deferred
def _determineClassName(x):
    c = _determineClass(x)
    try:
        return c.__name__
    except:
        try:
            return str(c)
        except:
            return '<BROKEN CLASS AT 0x%x>' % unsignedID(c)
示例#3
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)
示例#4
0
文件: _reflect.py 项目: jml/deferred
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)
示例#5
0
文件: _defer.py 项目: jml/deferred
 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)))
示例#6
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)))