traceback.print_exception(e, colorize=_colorize.can_colorize())
print("Uncaught exception. Entering post mortem debugging")
print("Running 'cont' or 'step' will restart the program")
- pdb.interaction(None, e)
- print(f"Post mortem debugger finished. The {target} will "
- "be restarted")
+ try:
+ pdb.interaction(None, e)
+ except Restart:
+ print("Restarting", target, "with arguments:")
+ print("\t" + " ".join(sys.argv[1:]))
+ continue
if pdb._user_requested_quit:
break
print("The program finished and will be restarted")
# the file as up to date
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):
self.module_name = 't_main'
os_helper.rmtree(self.module_name)