cpython
cpython copied to clipboard
inspect.signature includes bound argument for wrappers around decorated bound methods
| BPO | 29858 |
|---|---|
| Nosy | @1st1, @anton-ryzhov |
| PRs |
Note: 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:
assignee = None
closed_at = None
created_at = <Date 2017-03-20.09:19:13.208>
labels = ['type-bug', 'library', '3.9', '3.10', '3.11']
title = 'inspect.signature includes bound argument for wrappers around decorated bound methods'
updated_at = <Date 2022-01-21.12:39:17.450>
user = 'https://github.com/anton-ryzhov'
bugs.python.org fields:
activity = <Date 2022-01-21.12:39:17.450>
actor = 'iritkatriel'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2017-03-20.09:19:13.208>
creator = 'anton-ryzhov'
dependencies = []
files = []
hgrepos = []
issue_num = 29858
keywords = []
message_count = 2.0
messages = ['289879', '289880']
nosy_count = 2.0
nosy_names = ['yselivanov', 'anton-ryzhov']
pr_nums = ['736']
priority = 'normal'
resolution = None
stage = 'patch review'
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue29858'
versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']
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)
Related to http://bugs.python.org/issue24298