classification
Title: inspect.signature includes bound argument for wrappers around decorated bound methods
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.7, Python 3.6, Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: anton-ryzhov, yselivanov
Priority: normal Keywords:

Created on 2017-03-20 09:19 by anton-ryzhov, last changed 2017-03-20 09:35 by serhiy.storchaka.

Pull Requests
URL Status Linked Edit
PR 736 open anton-ryzhov, 2017-03-20 09:25
Messages (2)
msg289879 - (view) Author: (anton-ryzhov) * Date: 2017-03-20 09:19
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.

Reproduce:
```
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)
```
msg289880 - (view) Author: (anton-ryzhov) * Date: 2017-03-20 09:19
Related to http://bugs.python.org/issue24298
History
Date User Action Args
2017-03-20 09:35:21serhiy.storchakasetnosy: + yselivanov
stage: patch review
type: behavior

versions: - Python 3.3, Python 3.4
2017-03-20 09:25:29anton-ryzhovsetpull_requests: + pull_request650
2017-03-20 09:19:48anton-ryzhovsetmessages: + msg289880
2017-03-20 09:19:13anton-ryzhovcreate