Daniel Urban added the comment:

If I understand correctly, the invariant is that len(kw_defaults) == 
len(kwonlyargs). I think the reason is that the following is valid syntax (an 
argument without a default after one with a default):

>>> def f(*, a=0, b): pass
... 
>>>

And None is used as a placeholder in the kw_defaults list:
>>> ast.dump(ast.parse('def f(*, a=0, b): pass'))
"Module(body=[FunctionDef(name='f', args=arguments(args=[], vararg=None, 
varargannotation=None, kwonlyargs=[arg(arg='a', annotation=None), arg(arg='b', 
annotation=None)], kwarg=None, kwargannotation=None, defaults=[], 
kw_defaults=[Num(n=0), None]), body=[Pass()], decorator_list=[], 
returns=None)])"
>>>

So it seems to me, that this behavior is intentional. (Also, it works no 
differently in 3.2.)

----------

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

Reply via email to