cpython icon indicating copy to clipboard operation
cpython copied to clipboard

gh-74044: inspect.signature for wrappers around decorated bound methods

Open anton-ryzhov opened this issue 7 years ago • 13 comments

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

anton-ryzhov avatar Mar 20 '17 09:03 anton-ryzhov

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:

  1. 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
  2. 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)
  3. Reply here saying you have completed the above steps

Thanks again to your contribution and we look forward to looking at it!

the-knights-who-say-ni avatar Mar 20 '17 09:03 the-knights-who-say-ni

@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.

mention-bot avatar Mar 20 '17 09:03 mention-bot

@the-knights-who-say-ni Got "Contributor Form Received"

anton-ryzhov avatar Mar 20 '17 09:03 anton-ryzhov

@anton-ryzhov Good catch. The code looks OK, just add a comment explaining why your change works in all cases.

1st1 avatar Mar 21 '17 16:03 1st1

@1st1 In case you haven't received notification about last push, I'm notifying about this by the comment.

anton-ryzhov avatar Mar 23 '17 06:03 anton-ryzhov

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

vstinner avatar Jan 10 '19 16:01 vstinner

@1st1, I believe your requested changes have been made and this is ready for another review. Thanks!

csabella avatar Apr 10 '19 00:04 csabella

Closing and reopening to trigger tests.

csabella avatar Nov 16 '19 02:11 csabella

This PR is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Mar 18 '22 00:03 github-actions[bot]

This PR is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Aug 28 '22 00:08 github-actions[bot]

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

bedevere-bot avatar Nov 09 '22 11:11 bedevere-bot

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

bedevere-bot avatar Nov 09 '22 14:11 bedevere-bot

@anton-ryzhov This needs a news entry.

iritkatriel avatar Nov 09 '22 14:11 iritkatriel

Done

anton-ryzhov avatar Nov 09 '22 19:11 anton-ryzhov

Thanks @anton-ryzhov for the PR, and @iritkatriel for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. 🐍🍒⛏🤖

miss-islington avatar Nov 10 '22 12:11 miss-islington

GH-99328 is a backport of this pull request to the 3.11 branch.

bedevere-bot avatar Nov 10 '22 12:11 bedevere-bot

GH-99329 is a backport of this pull request to the 3.10 branch.

bedevere-bot avatar Nov 10 '22 12:11 bedevere-bot