Message239183
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. |
|
Date |
User |
Action |
Args |
2015-03-24 21:28:27 | terry.reedy | set | recipients:
+ terry.reedy, georg.brandl, python-dev, serhiy.storchaka |
2015-03-24 21:28:27 | terry.reedy | set | messageid: <1427232507.38.0.735840532996.issue23671@psf.upfronthosting.co.za> |
2015-03-24 21:28:27 | terry.reedy | link | issue23671 messages |
2015-03-24 21:28:27 | terry.reedy | create | |
|