Jon Waltman avatar Jon Waltman committed fc3c17b

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

Comments (0)

Files changed (2)

 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`.

sphinx/util/inspect.py

             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]:]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.