diff --git a/CHANGES b/CHANGES index 3ee4586a9..d6621621e 100644 --- a/CHANGES +++ b/CHANGES @@ -90,6 +90,8 @@ Bugs fixed * #7362: autodoc: does not render correct signatures for built-in functions * #7654: autodoc: ``Optional[Union[foo, bar]]`` is presented as ``Union[foo, bar, None]`` +* #7629: autodoc: autofunction emits an unfriendly warning if an invalid object + specified * #7551: autosummary: a nested class is indexed as non-nested class * #7535: sphinx-autogen: crashes when custom template uses inheritance * #7536: sphinx-autogen: crashes when template uses i18n feature diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 80bcc0e8d..3bd3630c3 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -1056,7 +1056,11 @@ class FunctionDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # typ self.env.app.emit('autodoc-before-process-signature', unwrapped, False) sig = inspect.signature(unwrapped) args = stringify_signature(sig, **kwargs) - except TypeError: + except TypeError as exc: + logger.warning(__("Failed to get a function signature for %s: %s"), + self.fullname, exc) + return None + except ValueError: args = '' if self.env.config.strip_signature_backslash: