8000 gh-102799: use sys.exception() instead of sys.exc_info() in pdb · iritkatriel/cpython@09e3f5b · GitHub
[go: up one dir, main page]

Skip to content

Commit 09e3f5b

Browse files
committed
pythongh-102799: use sys.exception() instead of sys.exc_info() in pdb
1 parent b4978ff commit 09e3f5b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Lib/pdb.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ def _getval_except(self, arg, frame=None):
12581258
return _rstr('** raised %s **' % self._format_exc(exc))
12591259

12601260
def _error_exc(self):
1261-
exc = sys.exc_info()[1]
1261+
exc = sys.exception()
12621262
self.error(self._format_exc(exc))
12631263

12641264
def _msg_val_func(self, arg, func):
@@ -1745,9 +1745,10 @@ def post_mortem(t=None):
17451745
"""
17461746
# handling the default
17471747
if t is None:
1748-
# sys.exc_info() returns (type, value, traceback) if an exception is
1749-
# being handled, otherwise it returns None
1750-
t = sys.exc_info()[2]
1748+
exc = sys.exception()
1749+
if exc is not None:
1750+
t = exc.__traceback__
1751+
17511752
if t is None:
17521753
raise ValueError("A valid traceback must be passed if no "
17531754
"exception is being handled")
@@ -1831,18 +1832,18 @@ def main():
18311832
except Restart:
18321833
print("Restarting", target, "with arguments:")
18331834
print("\t" + " ".join(sys.argv[1:]))
1834-
except SystemExit:
1835+
except SystemExit as e:
18351836
# In most cases SystemExit does not warrant a post-mortem session.
18361837
print("The program exited via sys.exit(). Exit status:", end=' ')
1837-
print(sys.exc_info()[1])
1838+
print(e)
18381839
except SyntaxError:
18391840
traceback.print_exc()
18401841
sys.exit(1)
1841-
except:
1842+
except BaseException as e:
18421843
traceback.print_exc()
18431844
print("Uncaught exception. Entering post mortem debugging")
18441845
print("Running 'cont' or 'step' will restart the program")
1845-
t = sys.exc_info()[2 4E0B ]
1846+
t = e.__traceback__
18461847
pdb.interaction(None, t)
18471848
print("Post mortem debugger finished. The " + target +
18481849
" will be restarted")

0 commit comments

Comments
 (0)
0