[New-bugs-announce] [issue4959] inspect.formatargspec fails for keyword args without defaults, affects help and likely pydoc
dariusp
report at bugs.python.org
Fri Jan 16 06:53:21 CET 2009
New submission from dariusp <dariusp at internode.on.net>:
Hi,
Suggested log message:
formatargspec now handles keyword only args that don't have defaults.
Previously it expected an empty dict but was being given None.
Patch:
The patch contains a suggested fix to inspect.py and a new test in
test_inspect.py and inspect_fodder2.py to demonstrate the issue.
Before:
>>> def foo(*, a):
... print(a)
...
>>> help(foo)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.0/site.py", line 427, in __call__
return pydoc.help(*args, **kwds)
File "/usr/local/lib/python3.0/pydoc.py", line 1672, in __call__
self.help(request)
File "/usr/local/lib/python3.0/pydoc.py", line 1716, in help
else: doc(request, 'Help on %s:')
File "/usr/local/lib/python3.0/pydoc.py", line 1504, in doc
pager(render_doc(thing, title, forceload))
File "/usr/local/lib/python3.0/pydoc.py", line 1499, in render_doc
return title % desc + '\n\n' + text.document(object, name)
File "/usr/local/lib/python3.0/pydoc.py", line 322, in document
if inspect.isroutine(object): return self.docroutine(*args)
File "/usr/local/lib/python3.0/pydoc.py", line 1263, in docroutine
formatannotation=inspect.formatannotationrelativeto(object))
File "/usr/local/lib/python3.0/inspect.py", line 895, in formatargspec
if kwonlyarg in kwonlydefaults:
TypeError: argument of type 'NoneType' is not iterable
After:
>>> def foo(*, a):
... print(a)
...
>>> help(foo)
Help on function foo in module __main__:
foo(*, a)
----------
components: Library (Lib)
files: inspect_keyworded_no_default.diff
keywords: patch
messages: 79932
nosy: dariusp
severity: normal
status: open
title: inspect.formatargspec fails for keyword args without defaults, affects help and likely pydoc
type: crash
versions: Python 3.0
Added file: http://bugs.python.org/file12760/inspect_keyworded_no_default.diff
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4959>
_______________________________________
More information about the New-bugs-announce
mailing list