Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-26053: Fix args echoed by pdb run command #22033

Merged
merged 7 commits into from
Apr 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/pdb.py
Original file line number Diff line number Diff line change
@@ -1707,7 +1707,7 @@ def main():
print("The program finished and will be restarted")
except Restart:
print("Restarting", mainpyfile, "with arguments:")
print("\t" + " ".join(args))
print("\t" + " ".join(sys.argv[1:]))
except SystemExit:
# In most cases SystemExit does not warrant a post-mortem session.
print("The program exited via sys.exit(). Exit status:", end=' ')
13 changes: 13 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
@@ -1443,6 +1443,19 @@ def test_issue16180(self):
'Fail to handle a syntax error in the debuggee.'
.format(expected, stdout))

def test_issue26053(self):
# run command of pdb prompt echoes the correct args
script = "print('hello')"
commands = """
continue
run a b c
run d e f
quit
"""
stdout, stderr = self.run_pdb_script(script, commands)
output = '\n'.join([x.strip() for x in stdout.splitlines()])
self.assertIn("Restarting main.py with arguments:\na b c", output)
self.assertIn("Restarting main.py with arguments:\nd e f", output)

def test_readrc_kwarg(self):
script = textwrap.dedent("""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed bug where the :mod:`pdb` interactive run command echoed the args from the shell command line, even if those have been overridden at the pdb prompt.