diff --git a/sphinx/events.py b/sphinx/events.py index 9a455d3d035..4dc5131e7ee 100644 --- a/sphinx/events.py +++ b/sphinx/events.py @@ -5,7 +5,6 @@ from __future__ import annotations -import contextlib from collections import defaultdict from operator import attrgetter from typing import TYPE_CHECKING, Any, NamedTuple @@ -90,8 +89,12 @@ def emit( """Emit a Sphinx event.""" # not every object likes to be repr()'d (think # random stuff coming via autodoc) - with contextlib.suppress(Exception): - logger.debug('[app] emitting event: %r%s', name, repr(args)[:100]) + try: + repr_args = repr(args) + except Exception: + pass + else: + logger.debug('[app] emitting event: %r%s', name, repr_args) results = [] listeners = sorted(self.listeners[name], key=attrgetter('priority'))