@@ -61,7 +61,10 @@ def full_exception_context(
6161 full_traceback : bool = True ,
6262) -> str :
6363 """Return a formatted message containing useful debugging context."""
64- last_msgs = '\n ' .join (f'* { strip_escape_sequences (s )} ' for s in message_log )
64+ messages = [f' { strip_escape_sequences (msg )} ' .rstrip () for msg in message_log ]
65+ while messages and not messages [- 1 ]:
66+ messages .pop ()
67+ last_msgs = '\n ' .join (messages )
6568 exts_list = '\n ' .join (
6669 f'* { ext .name } ({ ext .version } )'
6770 for ext in extensions
@@ -80,17 +83,14 @@ def format_traceback(
8083
8184 # format an exception with traceback, but only the last frame.
8285 te = TracebackException .from_exception (exception , limit = - 1 )
83- formatted_tb = (
84- te .stack .format ()[- 1 ] + '' .join (te .format_exception_only ()).rstrip ()
85- )
86- return formatted_tb
87- if isinstance (exception , SphinxParallelError ):
88- return f'(Error in parallel process)\n { exception .traceback } '
86+ exc_format = te .stack .format ()[- 1 ] + '' .join (te .format_exception_only ())
87+ elif isinstance (exception , SphinxParallelError ):
88+ exc_format = f'(Error in parallel process)\n { exception .traceback } '
8989 else :
9090 from traceback import format_exception
9191
9292 exc_format = '' .join (format_exception (exception ))
93- return exc_format
93+ return ' \n ' . join ( f' { line } ' for line in exc_format . rstrip (). splitlines ())
9494
9595
9696def error_info (messages : str , extensions : str , traceback : str ) -> str :
0 commit comments