inspect.signature removes initial starred method params (bug) #64600
Copy link
Copy link
Closed
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
| BPO | 20401 |
|---|---|
| Nosy | @terryjreedy, @ncoghlan, @larryhastings, @1st1, @mlouielu |
| Files |
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 = 'https://github.com/1st1'
closed_at = <Date 2014-01-28.17:27:33.930>
created_at = <Date 2014-01-27.02:16:33.088>
labels = ['type-bug']
title = 'inspect.signature removes initial starred method params (bug)'
updated_at = <Date 2017-05-02.02:22:59.304>
user = 'https://github.com/terryjreedy'bugs.python.org fields:
activity = <Date 2017-05-02.02:22:59.304>
actor = 'terry.reedy'
assignee = 'yselivanov'
closed = True
closed_date = <Date 2014-01-28.17:27:33.930>
closer = 'yselivanov'
components = []
creation = <Date 2014-01-27.02:16:33.088>
creator = 'terry.reedy'
dependencies = []
files = ['33758']
hgrepos = []
issue_num = 20401
keywords = ['patch']
message_count = 12.0
messages = ['209378', '209379', '209386', '209387', '209393', '209400', '209488', '209566', '209567', '292637', '292701', '292711']
nosy_count = 6.0
nosy_names = ['terry.reedy', 'ncoghlan', 'larry', 'python-dev', 'yselivanov', 'louielu']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'needs patch'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue20401'
versions = ['Python 3.3', 'Python 3.4']Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
terryjreedy commentedon Jan 27, 2014
*args should have been left in even for the bound method, as idlelib calltips do.
Since '*' is not a word character,
idlelib.Calltips._first_param = re.compile('(?<=\()\w*\,?\s*')
does not see '*args' as a substring to be deleted with
argspec = _first_param.sub("", argspec)
The same comment applies to
def meth2(**kwds): pass
even though calling the bound method would fail.
larryhastings commentedon Jan 27, 2014
Yury, can you look in to this?
I have been modifying inspect.signature, but (almost) exclusively in from_builtin. If this is my fault I'll be happy to fix it.
terryjreedy commentedon Jan 27, 2014
There does not appear to be a test for this. If so, this case may not have ever worked right. Here is the only failure at the moment (which should also be fixed).
larryhastings commentedon Jan 27, 2014
I just tried it in 3.3 (3.3.1rc1) and it had the same problem.
1st1 commentedon Jan 27, 2014
Yes, that's s bug. I'll take a look tomorrow.
terryjreedy commentedon Jan 27, 2014
Sorry, I should have said that I tried repository versions of both 3.3 and 3.4.
1st1 commentedon Jan 28, 2014
Patch is attached, please review.
Should we commit this to 3.3 too?
python-dev commentedon Jan 28, 2014
New changeset 3544827d42e6 by Yury Selivanov in branch 'default':
inspect.signature: Handle bound methods with '(*args)' signature correctly bpo-20401
http://hg.python.org/cpython/rev/3544827d42e6
1st1 commentedon Jan 28, 2014
Committed. Thank you, Terry.
mlouielu commentedon Apr 30, 2017
Is there any reason that the second case Terry provide still will failed with ValueError?
ip.signature(C().meth2)
1st1 commentedon May 1, 2017
Yes, the reason is that
C().meth2is an invalid method that can't be called. Try callingC().meth2()and you will get a TypeError.There is no bug here.
terryjreedy commentedon May 2, 2017
OK, we will change this example in test_calltips once calltips uses .signature (bpo-19903).