summaryrefslogtreecommitdiffstats
path: root/Lib/pdb.py
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-04-09 02:05:50 (GMT)
committerGitHub <noreply@github.com>2023-04-09 02:05:50 (GMT)
commit264b87f7fd0634485b9b4d21df49bec3401d7b2a (patch)
tree471cb89beef00d209b3d983bcb2c2720ebbe4e49 /Lib/pdb.py
parent83af8f268629139b9628ff53617671469167146a (diff)
downloadcpython-264b87f7fd0634485b9b4d21df49bec3401d7b2a.zip
cpython-264b87f7fd0634485b9b4d21df49bec3401d7b2a.tar.gz
cpython-264b87f7fd0634485b9b4d21df49bec3401d7b2a.tar.bz2
gh-102799: use `sys.exception()` instead of `sys.exc_info()` in pdb (#103294)
Diffstat (limited to 'Lib/pdb.py')
-rwxr-xr-xLib/pdb.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index e043b0d..e03142e 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -1258,7 +1258,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
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):
@@ -1755,9 +1755,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")
@@ -1841,18 +1842,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")