diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-03-18 11:47:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-18 11:47:11 (GMT) |
commit | e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7 (patch) | |
tree | 8363c72cc70b34e06fed5c39d86ec99047613799 /Lib/traceback.py | |
parent | 039714d00f147be4d018fa6aeaf174aad7e8fa32 (diff) | |
download | cpython-e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7.zip cpython-e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7.tar.gz cpython-e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7.tar.bz2 |
gh-102778: Add sys.last_exc, deprecate sys.last_type, sys.last_value,sys.last_traceback (#102779)
Diffstat (limited to 'Lib/traceback.py')
-rw-r--r-- | Lib/traceback.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Lib/traceback.py b/Lib/traceback.py index c43c472..9e720ac 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -179,7 +179,7 @@ def _safe_string(value, what, func=str): # -- def print_exc(limit=None, file=None, chain=True): - """Shorthand for 'print_exception(*sys.exc_info(), limit, file)'.""" + """Shorthand for 'print_exception(*sys.exc_info(), limit, file, chain)'.""" print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain) def format_exc(limit=None, chain=True): @@ -187,12 +187,16 @@ def format_exc(limit=None, chain=True): return "".join(format_exception(*sys.exc_info(), limit=limit, chain=chain)) def print_last(limit=None, file=None, chain=True): - """This is a shorthand for 'print_exception(sys.last_type, - sys.last_value, sys.last_traceback, limit, file)'.""" - if not hasattr(sys, "last_type"): + """This is a shorthand for 'print_exception(sys.last_exc, limit, file, chain)'.""" + if not hasattr(sys, "last_exc") and not hasattr(sys, "last_type"): raise ValueError("no last exception") - print_exception(sys.last_type, sys.last_value, sys.last_traceback, - limit, file, chain) + + if hasattr(sys, "last_exc"): + print_exception(sys.last_exc, limit, file, chain) + else: + print_exception(sys.last_type, sys.last_value, sys.last_traceback, + limit, file, chain) + # # Printing and Extracting Stacks. |