Message84417
inspect.formatargspec is not able to handle functions with keyword only
arguments without the default values (probably rare, but still allowed).
This has also impact on help command which is then unable to show proper
help page for such functions.
Offending function examples:
def fun1(arg, defarg=None, *args, kwonly):
"""Some documentation."""
return arg, defarg, args, kwonly
def fun2(arg, defarg=None, *, kwonly):
"""Some documentation."""
return arg, defarg, kwonly
The fix is easy:
897c897
< if kwonlyarg in kwonlydefaults:
---
> if kwonlydefaults and kwonlyarg in kwonlydefaults:
For the test following code snippet taken from help module (or help) can
be used:
import inspect
def trybug(fun):
args, varargs, varkw, defaults, kwonlyargs, kwdefaults, ann = \
inspect.getfullargspec(fun)
argspec = inspect.formatargspec(
args, varargs, varkw, defaults, kwonlyargs, kwdefaults, ann,
formatannotation=inspect.formatannotationrelativeto(object)) |
|
Date |
User |
Action |
Args |
2009-03-29 17:41:13 | petr.dolezal | set | recipients:
+ petr.dolezal |
2009-03-29 17:41:13 | petr.dolezal | set | messageid: <1238348473.08.0.854037190303.issue5597@psf.upfronthosting.co.za> |
2009-03-29 17:41:11 | petr.dolezal | link | issue5597 messages |
2009-03-29 17:41:10 | petr.dolezal | create | |
|