# Buggy code
def emit(self, name: str, *args: Any) -> List:
    """Emit a Sphinx event."""
    try:
        logger.debug("[app] emitting event: %r%s", name, repr(args)[:100])
    except Exception:
        # not every object likes to be repr()'d (think
        # random stuff coming via autodoc)
        pass

    results = []
    listeners = sorted(self.listeners[name], key=attrgetter("priority"))
    for listener in listeners:
        if self.app is None:
            # for compatibility; RemovedInSphinx40Warning
            results.append(listener.handler(*args))
        else:
            results.append(listener.handler(self.app, *args))
    return results


# Traceback (TypeError)
WARNING: error while formatting arguments for errno.EINTR:
Traceback (most recent call last):
File "/Users/tkomiya/work/sphinx/sphinx/ext/autodoc/__init__.py", line 1049, in format_args
sig = inspect.signature(unwrapped)
File "/Users/tkomiya/work/sphinx/sphinx/util/inspect.py", line 406, in signature
signature = inspect.signature(subject)
File "/Users/tkomiya/.pyenv/versions/3.8.2/lib/python3.8/inspect.py", line 3093, in signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
File "/Users/tkomiya/.pyenv/versions/3.8.2/lib/python3.8/inspect.py", line 2842, in from_callable
return _signature_from_callable(obj, sigcls=cls,
File "/Users/tkomiya/.pyenv/versions/3.8.2/lib/python3.8/inspect.py", line 2216, in _signature_from_callable
raise TypeError('{!r} is not a callable object'.format(obj))
TypeError: 4 is not a callable object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/tkomiya/work/sphinx/sphinx/ext/autodoc/__init__.py", line 395, in format_signature
args = self.format_args(**kwargs)
File "/Users/tkomiya/work/sphinx/sphinx/ext/autodoc/__init__.py", line 1052, in format_args
if (inspect.is_builtin_class_method(unwrapped, '__new__') and
File "/Users/tkomiya/work/sphinx/sphinx/util/inspect.py", line 392, in is_builtin_class_method
classes = [c for c in inspect.getmro(obj) if attr_name in c.__dict__]
File "/Users/tkomiya/.pyenv/versions/3.8.2/lib/python3.8/inspect.py", line 489, in getmro
return cls.__mro__
AttributeError: 'int' object has no attribute '__mro__'

# Fixed code
def emit(self, name: str, *args: Any) -> List:
    """Emit a Sphinx event."""
    try:
        logger.debug("[app] emitting event: %r%s", name, repr(args)[:100])
    except Exception:
        # not every object likes to be repr()'d (think
        # random stuff coming via autodoc)
        pass

    results = []
    listeners = sorted(self.listeners[name], key=attrgetter("priority"))
    for listener in listeners:
        try:
            if self.app is None:
                # for compatibility; RemovedInSphinx40Warning
                results.append(listener.handler(*args))
            else:
                results.append(listener.handler(self.app, *args))
        except SphinxError:
            raise
        except Exception as exc:
            raise ExtensionError(
                __("Handler %r for event %r threw an exception")
                % (listener.handler, name)
            ) from exc
    return results