[3.13] gh-118714: Make the pdb post-mortem restart/quit behavior more reasonable (GH-118725) (#121346)

gh-118714: Make the pdb post-mortem restart/quit behavior more reasonable (GH-118725)
(cherry picked from commit e245ed7d1e)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
This commit is contained in:
Miss Islington (bot) 2024-07-03 21:15:53 +02:00 committed by GitHub
parent 3d4e533be5
commit e7008d78f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 3 deletions

View File

@ -2460,9 +2460,12 @@ def main():
traceback.print_exception(e, colorize=_colorize.can_colorize()) traceback.print_exception(e, colorize=_colorize.can_colorize())
print("Uncaught exception. Entering post mortem debugging") print("Uncaught exception. Entering post mortem debugging")
print("Running 'cont' or 'step' will restart the program") print("Running 'cont' or 'step' will restart the program")
pdb.interaction(None, e) try:
print(f"Post mortem debugger finished. The {target} will " pdb.interaction(None, e)
"be restarted") except Restart:
print("Restarting", target, "with arguments:")
print("\t" + " ".join(sys.argv[1:]))
continue
if pdb._user_requested_quit: if pdb._user_requested_quit:
break break
print("The program finished and will be restarted") print("The program finished and will be restarted")

View File

@ -3492,6 +3492,23 @@ def bœr():
# the file as up to date # the file as up to date
self.assertNotIn("WARNING:", stdout) self.assertNotIn("WARNING:", stdout)
def test_post_mortem_restart(self):
script = """
def foo():
raise ValueError("foo")
foo()
"""
commands = """
continue
restart
continue
quit
"""
stdout, stderr = self.run_pdb_script(script, commands)
self.assertIn("Restarting", stdout)
def test_relative_imports(self): def test_relative_imports(self):
self.module_name = 't_main' self.module_name = 't_main'
os_helper.rmtree(self.module_name) os_helper.rmtree(self.module_name)

View File

@ -0,0 +1,2 @@
Allow ``restart`` in post-mortem debugging of :mod:`pdb`. Removed restart message
when the user quits pdb from post-mortem mode.