Terry J. Reedy added the comment:

This is a nice catch of a subtle bug and a nice fix.  I verified that replacing 
'self' with '*args' does not simply shift the problem from 'self' to 'args'.

>>> class C:
        def test(*args, **kwargs):
                print(args, kwargs )
        
>>> c = C()
>>> c.test(1, args=2, kwargs=3, self=4)
(<__main__.C object at 0x00000000035FE128>, 1) {'args': 2, 'kwargs': 3, 'self': 
4}

While the * and ** names are, like parameter names, local names given in the 
signature header, they are not counted as parameter names in the code object 
.co_argcount or .co_kwonlyargcount attributes that are used along with 
co_varnames in the name-argument matching process.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23671>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to