Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Jan 10, 2025
1 parent 3e1208e commit 2a627fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions sphinx/_cli/util/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion sphinx/cmd/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,15 +36,18 @@ 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,
use_pdb=args.pdb,
print_traceback=args.verbosity or args.traceback,
message_log=message_log,
extensions=extensions,
print_full_traceback=print_full_traceback,
)


Expand Down Expand Up @@ -435,15 +437,18 @@ 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,
use_pdb=args.pdb,
print_traceback=args.verbosity or args.traceback,
message_log=message_log,
extensions=extensions,
print_full_traceback=print_full_traceback,
)
return 2
finally:
Expand Down

0 comments on commit 2a627fe

Please sign in to comment.