This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author petr.dolezal
Recipients petr.dolezal
Date 2009-03-29.17:41:10
SpamBayes Score 4.797615e-08
Marked as misclassified No
Message-id <1238348473.08.0.854037190303.issue5597@psf.upfronthosting.co.za>
In-reply-to
Content
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))
History
Date User Action Args
2009-03-29 17:41:13petr.dolezalsetrecipients: + petr.dolezal
2009-03-29 17:41:13petr.dolezalsetmessageid: <1238348473.08.0.854037190303.issue5597@psf.upfronthosting.co.za>
2009-03-29 17:41:11petr.dolezallinkissue5597 messages
2009-03-29 17:41:10petr.dolezalcreate