diff --git a/CHANGES b/CHANGES index c5ae5c1a8..c4f8e22c1 100644 --- a/CHANGES +++ b/CHANGES @@ -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`. diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 1227b17c0..8cd93eafe 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -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]:]