mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-118893: Evaluate all statements in the new REPL separately (#119318)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
9fa206aaec
commit
a3e4fec873
5 changed files with 128 additions and 9 deletions
|
@ -155,7 +155,7 @@ def format_exception(exc, /, value=_sentinel, tb=_sentinel, limit=None, \
|
|||
return list(te.format(chain=chain, colorize=colorize))
|
||||
|
||||
|
||||
def format_exception_only(exc, /, value=_sentinel, *, show_group=False):
|
||||
def format_exception_only(exc, /, value=_sentinel, *, show_group=False, **kwargs):
|
||||
"""Format the exception part of a traceback.
|
||||
|
||||
The return value is a list of strings, each ending in a newline.
|
||||
|
@ -170,10 +170,11 @@ def format_exception_only(exc, /, value=_sentinel, *, show_group=False):
|
|||
:exc:`BaseExceptionGroup`, the nested exceptions are included as
|
||||
well, recursively, with indentation relative to their nesting depth.
|
||||
"""
|
||||
colorize = kwargs.get("colorize", False)
|
||||
if value is _sentinel:
|
||||
value = exc
|
||||
te = TracebackException(type(value), value, None, compact=True)
|
||||
return list(te.format_exception_only(show_group=show_group))
|
||||
return list(te.format_exception_only(show_group=show_group, colorize=colorize))
|
||||
|
||||
|
||||
# -- not official API but folk probably use these two functions.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue