[issue41232] Python `functools.wraps` doesn't deal with defaults correctly
Jelle Zijlstra
report at bugs.python.org
Sat May 1 23:52:37 EDT 2021
Jelle Zijlstra <jelle.zijlstra at gmail.com> added the comment:
We should not do this, because the wrapping function may have different defaults, and updating __defaults__ would make it use the wrapped function's defaults.
Example:
>>> def f(y=1):
... print(y)
...
>>> f()
1
>>> f.__defaults__
(1,)
>>> f.__defaults__ = ()
>>> f()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() missing 1 required positional argument: 'y'
----------
nosy: +Jelle Zijlstra
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41232>
_______________________________________
More information about the Python-bugs-list
mailing list