Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 264b87f

Browse filesBrowse files
authored
pythongh-102799: use sys.exception() instead of sys.exc_info() in pdb (python#103294)
1 parent 83af8f2 commit 264b87f
Copy full SHA for 264b87f

File tree

1 file changed

+9
-8
lines changed
Filter options

1 file changed

+9
-8
lines changed

‎Lib/pdb.py

Copy file name to clipboardExpand all lines: Lib/pdb.py
+9-8Lines 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):
@@ -1755,9 +1755,10 @@ def post_mortem(t=None):
17551755
"""
17561756
# handling the default
17571757
if t is None:
1758-
# sys.exc_info() returns (type, value, traceback) if an exception is
1759-
# being handled, otherwise it returns None
1760-
t = sys.exc_info()[2]
1758+
exc = sys.exception()
1759+
if exc is not None:
1760+
t = exc.__traceback__
1761+
17611762
if t is None:
17621763
raise ValueError("A valid traceback must be passed if no "
17631764
"exception is being handled")
@@ -1841,18 +1842,18 @@ def main():
18411842
except Restart:
18421843
print("Restarting", target, "with arguments:")
18431844
print("\t" + " ".join(sys.argv[1:]))
1844-
except SystemExit:
1845+
except SystemExit as e:
18451846
# In most cases SystemExit does not warrant a post-mortem session.
18461847
print("The program exited via sys.exit(). Exit status:", end=' ')
1847-
print(sys.exc_info()[1])
1848+
print(e)
18481849
except SyntaxError:
18491850
traceback.print_exc()
18501851
sys.exit(1)
1851-
except:
1852+
except BaseException as e:
18521853
traceback.print_exc()
18531854
print("Uncaught exception. Entering post mortem debugging")
18541855
print("Running 'cont' or 'step' will restart the program")
1855-
t = sys.exc_info()[2]
1856+
t = e.__traceback__
18561857
pdb.interaction(None, t)
18571858
print("Post mortem debugger finished. The " + target +
18581859
" will be restarted")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.