def unproxy(proxy): """Return a new copy of the original function of method behind a proxy. The result behaves like the original function in that calling it does not trigger compilation nor execution of any compiled code.""" if isinstance(proxy, types.FunctionType): return _psyco.unproxycode(proxy.func_code) if isinstance(proxy, types.MethodType): f = unproxy(proxy.im_func) return new.instancemethod(f, proxy.im_self, proxy.im_class) raise TypeError, "%s objects cannot be proxies" % type(proxy).__name__
def unbind(x): """Reverse of bind().""" if isinstance(x, types.MethodType): x = x.im_func if isinstance(x, types.FunctionType): try: f = _psyco.unproxycode(x.func_code) except error: pass else: x.func_code = f.func_code return if hasattr(x, "__dict__"): for o in x.__dict__.values(): if isinstance(o, types.MethodType) or isinstance(o, types.FunctionType): unbind(o) return raise TypeError, "cannot unbind %s objects" % type(x).__name__
def unbind(x): """Reverse of bind().""" if isinstance(x, types.MethodType): x = x.im_func if isinstance(x, types.FunctionType): try: f = _psyco.unproxycode(x.func_code) except error: pass else: x.func_code = f.func_code return if hasattr(x, '__dict__'): for o in x.__dict__.values(): if (isinstance(o, types.MethodType) or isinstance(o, types.FunctionType)): unbind(o) return raise TypeError, "cannot unbind %s objects" % type(x).__name__