Closes #1069: Fix autodoc signature formatting of "partial" functions without kwargs (patch by Artur Gaspar).

This commit is contained in:
Jonathan Waltman 2013-01-09 08:42:59 -06:00
parent bba6104b84
commit 61e951d2ed
2 changed files with 10 additions and 2 deletions

View File

@ -1,6 +1,9 @@
Release 1.2 (in development)
============================
* #1069: Fixed error caused when autodoc would try to format signatures of
"partial" functions without keyword arguments (patch by Artur Gaspar).
* The :confval:`latex_documents`, :confval:`texinfo_documents`, and
:confval:`man_pages` configuration values will be set to default values based
on the :confval:`master_doc` if not explicitly set in :file:`conf.py`.

View File

@ -27,13 +27,18 @@ if sys.version_info >= (2, 5):
func = func.im_func
parts = 0, ()
if type(func) is partial:
parts = len(func.args), func.keywords.keys()
keywords = func.keywords
if keywords is None:
keywords = {}
parts = len(func.args), keywords.keys()
func = func.func
if not inspect.isfunction(func):
raise TypeError('%r is not a Python function' % func)
args, varargs, varkw = inspect.getargs(func.func_code)
func_defaults = func.func_defaults
if func_defaults:
if func_defaults is None:
func_defaults = []
else:
func_defaults = list(func_defaults)
if parts[0]:
args = args[parts[0]:]