]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-26053: Fix args echoed by pdb run command (#22033)
authorIrit Katriel <iritkatriel@yahoo.com>
Thu, 1 Apr 2021 15:25:59 +0000 (16:25 +0100)
committerGitHub <noreply@github.com>
Thu, 1 Apr 2021 15:25:59 +0000 (08:25 -0700)
Lib/pdb.py
Lib/test/test_pdb.py
Misc/NEWS.d/next/Library/2020-09-01-10-12-13.bpo-26053.hXikw_.rst [new file with mode: 0644]

index 7a5192cbadc3adda0876f30fffae63965cca8d1a..98dc975eafafdcf364c2de8d04e591fbe64cfb2b 100755 (executable)
@@ -1708,7 +1708,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=' ')
index 51cd378648378e4dd4b942e506128c2cd20b3ca5..9f0db02996f5b6aaaf002430d97170119e1a10e3 100644 (file)
@@ -1443,6 +1443,19 @@ def bœr():
             '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("""
diff --git a/Misc/NEWS.d/next/Library/2020-09-01-10-12-13.bpo-26053.hXikw_.rst b/Misc/NEWS.d/next/Library/2020-09-01-10-12-13.bpo-26053.hXikw_.rst
new file mode 100644 (file)
index 0000000..e8720ac
--- /dev/null
@@ -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.