New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decorator with paren tokens in arguments breaks inspect.getsource #83035
Comments
|
Python 3.7.5 and 3.8.0 from collections import defaultdict
from functools import wraps
import inspect
def foo(*args):
def decorator(func):
@wraps(func)
def wrapper():
pass
return wrapper
return decorator
@foo(dict(), defaultdict(lambda: 1))
def f():
pass
print(inspect.getsource(f))Output: Expected output: These changes to the decorator parameters cause the problem to disappear:
|
|
Thanks for the report! Turns out this was a bug in Just submitted a PR #17374 to address this issue. |
|
Looks like there have been three PRs here already, but all of them seem to be incomplete and/or abandoned. Opened a new one: #99654 |
…rce (pythonGH-99654) (cherry picked from commit 68e4129) Co-authored-by: Carl Meyer <carl@oddbird.net>
…rce (pythonGH-99654) (cherry picked from commit 68e4129) Co-authored-by: Carl Meyer <carl@oddbird.net>
…rce (pythonGH-99654) (cherry picked from commit 68e4129) Co-authored-by: Carl Meyer <carl@oddbird.net>
|
Fixed and backported. Thanks @carljm! |
crusaderky mannequin commentedNov 19, 2019
•
edited by bedevere-bot
inspect.getsourceto properly extract source for decorated functions #17374Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: