Message318892
I am seeing an issue when attempting to use default kwargs in decorated functions.
I would post reproduction steps, but instead I have written a snippet which should showcase the issue.
Snippet:
```python
def decorator():
def inner(f):
def wrapper(*args, **kwargs):
# Zoinks, Scoob!
print('Decorator: {}'.format(''.join(kwargs.values())))
print(f(*args, **kwargs))
return wrapper
return inner
@decorator()
def func(foo='wont print in the decorator'):
return 'Func: {}'.format(foo)```
The following calls to 'func' should show you what Im talking about clearly:
```
func()
-> Decorator:
-> Func: wont print in the decorator
func(foo='will print in the decorator')
-> Decorator: will print in the decorator
-> Func: will print in the decorator
```
I would expect, though correct me if I am wrong, that both of these calls should print in the decorator and the function call.
For convenience, some REPL.it links:
3.6.1 -> https://repl.it/@SalomonSmeke/Python3-Decorator-Bug
2.7.10 -> https://repl.it/@SalomonSmeke/Python-Decorator-Bug
Using @wrap from functools:
2.7.10 -> https://repl.it/@SalomonSmeke/Python-Decorator-Bug-using-FuncTools
Thank you for your time.
P.S.
This is my first issue submitted to Python, please let me know if there is detail lacking. Im happy to provide what I can. |
|
Date |
User |
Action |
Args |
2018-06-07 05:12:25 | ssmeke | set | recipients:
+ ssmeke |
2018-06-07 05:12:25 | ssmeke | set | messageid: <1528348345.08.0.592728768989.issue33790@psf.upfronthosting.co.za> |
2018-06-07 05:12:25 | ssmeke | link | issue33790 messages |
2018-06-07 05:12:24 | ssmeke | create | |
|