Skip to content

gh-102799: use sys.exception() instead of sys.exc_info() in pdb #103294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ def _getval_except(self, arg, frame=None):
return _rstr('** raised %s **' % self._format_exc(exc))

def _error_exc(self):
exc = sys.exc_info()[1]
exc = sys.exception()
self.error(self._format_exc(exc))

def _msg_val_func(self, arg, func):
Expand Down Expand Up @@ -1745,9 +1745,10 @@ def post_mortem(t=None):
"""
# handling the default
if t is None:
# sys.exc_info() returns (type, value, traceback) if an exception is
# being handled, otherwise it returns None
t = sys.exc_info()[2]
exc = sys.exception()
if exc is not None:
t = exc.__traceback__

if t is None:
raise ValueError("A valid traceback must be passed if no "
"exception is being handled")
Expand Down Expand Up @@ -1831,18 +1832,18 @@ def main():
except Restart:
print("Restarting", target, "with arguments:")
print("\t" + " ".join(sys.argv[1:]))
except SystemExit:
except SystemExit as e:
# In most cases SystemExit does not warrant a post-mortem session.
print("The program exited via sys.exit(). Exit status:", end=' ')
print(sys.exc_info()[1])
print(e)
except SyntaxError:
traceback.print_exc()
sys.exit(1)
except:
except BaseException as e:
traceback.print_exc()
print("Uncaught exception. Entering post mortem debugging")
print("Running 'cont' or 'step' will restart the program")
t = sys.exc_info()[2]
t = e.__traceback__
pdb.interaction(None, t)
print("Post mortem debugger finished. The " + target +
" will be restarted")
Expand Down