New submission from Petr Dolezal <petr.dole...@matfyz.cz>:

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))

----------
components: Library (Lib)
messages: 84417
nosy: petr.dolezal
severity: normal
status: open
title: inspect.formatargspec crashes on missing kwonlydefaults
type: behavior
versions: Python 3.0

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

Reply via email to