Zachary Ware added the comment:
I agree with Josh; I don't think there's any bug here. To confirm, I expanded
on your example, reproduced below. Have a look at and play around with this,
and if you still believe something is wrong, ask on python-list and the folks
there should be able to hel
Josh Rosenberg added the comment:
I don't think you understand how wrapping works. At the time you're enumerating
the stack, the wrapped function has not actually been called. Only the wrapper
has been called. If the stack included "junk" when junk had not yet been
executed, the stack would be
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)
... retur