diff --git a/CHANGES b/CHANGES index 4198395c61b..5d5a2b2b353 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,7 @@ Bugs fixed * #7808: autodoc: Warnings raised on variable and attribute type annotations * #7802: autodoc: EOFError is raised on parallel build +* #7821: autodoc: TypeError is raised for overloaded C-ext function * #7812: autosummary: generates broken stub files if the target code contains an attribute and module that are same name * #7811: sphinx.util.inspect causes circular import problem diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 64b56847b37..754c4fddaf2 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -1237,7 +1237,11 @@ def annotate_to_first_argument(self, func: Callable, typ: Type) -> None: params = list(sig.parameters.values()) if params[0].annotation is Parameter.empty: params[0] = params[0].replace(annotation=typ) - func.__signature__ = sig.replace(parameters=params) # type: ignore + try: + func.__signature__ = sig.replace(parameters=params) # type: ignore + except TypeError: + # failed to update signature (ex. built-in or extension types) + return class SingledispatchFunctionDocumenter(FunctionDocumenter): @@ -1833,7 +1837,11 @@ def annotate_to_first_argument(self, func: Callable, typ: Type) -> None: params = list(sig.parameters.values()) if params[1].annotation is Parameter.empty: params[1] = params[1].replace(annotation=typ) - func.__signature__ = sig.replace(parameters=params) # type: ignore + try: + func.__signature__ = sig.replace(parameters=params) # type: ignore + except TypeError: + # failed to update signature (ex. built-in or extension types) + return class SingledispatchMethodDocumenter(MethodDocumenter):