From 2a627fe6a4f6812eaa96ad63d4caa67898e68759 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:57:53 +0000 Subject: [PATCH] lint --- sphinx/_cli/util/errors.py | 5 +++-- sphinx/cmd/build.py | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sphinx/_cli/util/errors.py b/sphinx/_cli/util/errors.py index 0e0dc38cc6c..e657a374d8c 100644 --- a/sphinx/_cli/util/errors.py +++ b/sphinx/_cli/util/errors.py @@ -156,6 +156,7 @@ def handle_exception( print_traceback: bool = False, message_log: Collection[str] = (), extensions: Collection[Extension] = (), + print_full_traceback: bool = False, ) -> None: from bdb import BdbQuit from traceback import TracebackException @@ -225,11 +226,11 @@ def print_red(*values: str) -> None: print_red(__('Exception occurred:')) print_err(formatted_tb) - traceback_output = format_traceback( + traceback_output = full_exception_context( exception, message_log=message_log, extensions=extensions ) traceback_info_path = write_temporary_file(traceback_output) - if not app or app.config.print_traceback: + if print_full_traceback: print_err(traceback_output) print_err(__('The full traceback has been saved in:')) print_err(traceback_info_path) diff --git a/sphinx/cmd/build.py b/sphinx/cmd/build.py index affb0aa92f4..c0c998a1417 100644 --- a/sphinx/cmd/build.py +++ b/sphinx/cmd/build.py @@ -13,7 +13,6 @@ import sphinx._cli.util.errors import sphinx.locale from sphinx import __display_version__ -from sphinx._cli.util.errors import format_traceback, write_temporary_file from sphinx.application import Sphinx from sphinx.locale import __ from sphinx.util._io import TeeStripANSI @@ -37,8 +36,10 @@ def handle_exception( if app is not None: message_log: Sequence[str] = app.messagelog extensions: Collection[Extension] = app.extensions.values() + print_full_traceback: bool = app.config.print_traceback else: message_log = extensions = () + print_full_traceback = True return sphinx._cli.util.errors.handle_exception( exception, stderr=stderr, @@ -46,6 +47,7 @@ def handle_exception( print_traceback=args.verbosity or args.traceback, message_log=message_log, extensions=extensions, + print_full_traceback=print_full_traceback, ) @@ -435,8 +437,10 @@ def build_main(argv: Sequence[str]) -> int: if app is not None: message_log: Sequence[str] = app.messagelog extensions: Collection[Extension] = app.extensions.values() + print_full_traceback: bool = app.config.print_traceback else: message_log = extensions = () + print_full_traceback = True sphinx._cli.util.errors.handle_exception( exc, stderr=args.error, @@ -444,6 +448,7 @@ def build_main(argv: Sequence[str]) -> int: print_traceback=args.verbosity or args.traceback, message_log=message_log, extensions=extensions, + print_full_traceback=print_full_traceback, ) return 2 finally: