cpython
cpython copied to clipboard
gh-74044: inspect.signature for wrappers around decorated bound methods
If we wrap function with bound method, which is also a wrapper around function, inspect.signature
will not do skip_bound_arg
.
It will use inspect.unwrap
and pass by bound method from outer function to inner one.
Reproducer:
import functools, inspect
def decorator(func):
@functools.wraps(func)
def inner(*args):
return func(*args)
return inner
class Foo(object):
@decorator
def bar(self, testarg):
pass
f = Foo()
baz = decorator(f.bar)
assert inspect.signature(baz) == inspect.signature(f.bar)
- Issue: gh-74044
Hello, and thanks for your contribution!
I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).
Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow these steps to rectify the issue:
- Sign the PSF contributor agreement. The "bugs.python.org username" requested by the form is the "Login name" field in "Your Details" at b.p.o
- Wait at least one US business day and then check the "Contributor form received entry under "Your Details" on bugs.python.org to see if your account has been marked as having signed the CLA (the delay is due to a person having to manually check your signed CLA)
- Reply here saying you have completed the above steps
Thanks again to your contribution and we look forward to looking at it!
@anton-ryzhov, thanks for your PR! By analyzing the history of the files in this pull request, we identified @1st1, @larryhastings and @zestyping to be potential reviewers.
@the-knights-who-say-ni Got "Contributor Form Received"
@anton-ryzhov Good catch. The code looks OK, just add a comment explaining why your change works in all cases.
@1st1 In case you haven't received notification about last push, I'm notifying about this by the comment.
I removed the " needs backport to 3.6" label, the 3.6 branch no longer accept bugfixes (only security fixes are accepted): https://devguide.python.org/#status-of-python-branches
@1st1, I believe your requested changes have been made and this is ready for another review. Thanks!
Closing and reopening to trigger tests.
This PR is stale because it has been open for 30 days with no activity.
This PR is stale because it has been open for 30 days with no activity.
Most changes to Python require a NEWS entry.
Please add it using the blurb_it web app or the blurb command-line tool.
Most changes to Python require a NEWS entry.
Please add it using the blurb_it web app or the blurb command-line tool.
@anton-ryzhov This needs a news entry.
Done
Thanks @anton-ryzhov for the PR, and @iritkatriel for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. 🐍🍒⛏🤖
GH-99328 is a backport of this pull request to the 3.11 branch.
GH-99329 is a backport of this pull request to the 3.10 branch.