[issue33790] Decorated (inner/wrapped) function kwarg defaults dont pass through decorator.

Steven D'Aprano report at bugs.python.org
Thu Jun 7 02:15:34 EDT 2018


Steven D'Aprano <steve+python at pearwood.info> added the comment:

I think you have misunderstood where and when default arguments are assigned. When you call func() with no arguments, kwargs is empty, and it is correct that the output will be

-> Decorator: 

In the following line, you call the original function, f(), again with no arguments. Then, and ONLY then, is the default argument for foo applied. Only the innermost function "func" knows that there is a parameter called foo with the given default. Hence the next output is 

-> Func: wont print in the decorator

as that is applying the default.

So I think the behaviour is correct. It is certainly the behaviour I would expect, so unless I'm misunderstanding your bug report, I think this is working as designed.

I'm going to close this report now, but if you think I've misunderstood anything and want to reopen it with more details, please do so.

----------
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33790>
_______________________________________


More information about the Python-bugs-list mailing list