Improved command `btx` (backtrace)
Detects stc-compiled method and show their frames Class >> selector instead
of showing stx-mangled C function name.
Also catches an error and prints backtrace in case there's problem in
the code (unhandled exception etc)
import types
class Decorator ( object ):
'''
Generic decorator class
'''
_obj = None
def __init__ ( self , obj ):
object.__setattr__(self, "_obj", obj)
def target(self):
return self._obj
def __getattr__(self, aname):
target = self._obj
f = getattr(target, aname)
if isinstance(f, types.MethodType):
# Rebind the method to the target.
return new.instancemethod(f.im_func, self, target.__class__)
else:
return f
def __repr__( self ):
return "[" +str(self.__class__) + ' : ' + self._obj.__repr__() + "]"