FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-102799: replace sys.exc_info by sys.exception in inspect and traceback modules by iritkatriel · Pull Request #104032 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 3 additions & 1 deletion Lib/inspect.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,9 @@ def stack(context=1):

def trace(context=1):
"""Return a list of records for the stack below the current exception."""
return getinnerframes(sys.exc_info()[2], context)
exc = sys.exception()
tb = None if exc is None else exc.__traceback__
return getinnerframes(tb, context)


# ------------------------------------------------ static version of getattr
Expand Down
6 changes: 3 additions & 3 deletions Lib/traceback.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ 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, chain)'."""
print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
"""Shorthand for 'print_exception(sys.exception(), limit, file, chain)'."""
print_exception(sys.exception(), limit=limit, file=file, chain=chain)

def format_exc(limit=None, chain=True):
"""Like print_exc() but return a string."""
return "".join(format_exception(*sys.exc_info(), limit=limit, chain=chain))
return "".join(format_exception(sys.exception(), limit=limit, chain=chain))

def print_last(limit=None, file=None, chain=True):
"""This is a shorthand for 'print_exception(sys.last_exc, limit, file, chain)'."""
Expand Down

Back | FazBrowse Home | New Git URL