-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Decorator with paren tokens in arguments breaks inspect.getsource #83035
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
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 <[email protected]>
…rce (pythonGH-99654) (cherry picked from commit 68e4129) Co-authored-by: Carl Meyer <[email protected]>
…rce (pythonGH-99654) (cherry picked from commit 68e4129) Co-authored-by: Carl Meyer <[email protected]>
…H-99654) (cherry picked from commit 68e4129) Co-authored-by: Carl Meyer <[email protected]>
…H-99654) (cherry picked from commit 68e4129) Co-authored-by: Carl Meyer <[email protected]>
Fixed and backported. Thanks @carljm! 🎉 |
Uh oh!
There was an error while loading. Please reload this page.
inspect.getsource
to 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: