New submission from the mulhern: >>> def decorator(f): ... @functools.wraps(f) ... def new_func(self, junk): ... stack = inspect.stack() ... for i, frame in enumerate(stack): ... print("%s" % frame[3]) ... f(self, junk) ... return new_func ... >>> @decorator ... def junk(self, p): ... print("%s" % junk.__name__) ... >>> junk("a", "b") new_func <module> junk >>> junk.__name__ 'junk'
Note that the wrapper function itself inspects the stack, printing out the names of methods on the stack. Note that "junk", the name of the wrapped function does not appear on the stack, it is only printed out by the junk method itself. I think that the name of the function at the top of the stack should be the name of the wrapped function, not of its wrapper. The name of the wrapper function should not appear at all. ---------- components: Interpreter Core messages: 220863 nosy: the.mulhern priority: normal severity: normal status: open title: stack frame contains name of wrapper method, not that of wrapped method type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21794> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com