]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.9] bpo-42383: pdb: do not fail to restart the target if the current directory...
authorAndrey Bienkowski <hexagonrecursion@gmail.com>
Tue, 26 Jan 2021 15:57:58 +0000 (15:57 +0000)
committerGitHub <noreply@github.com>
Tue, 26 Jan 2021 15:57:58 +0000 (07:57 -0800)
Lib/test/test_pdb.py
Misc/NEWS.d/next/Library/2020-11-17-14-30-12.bpo-42383.ubl0Y_.rst [new file with mode: 0644]

index e1a13cbaf3ef8498274e692edf844c2492d92afa..6c4eaf318e448005e7c65c173e9dfb56f29f9e1f 100644 (file)
@@ -1702,6 +1702,29 @@ def bœr():
 
             self.assertEqual(stdout.split('\n')[2].rstrip('\r'), expected)
 
+    def test_issue42383(self):
+        with support.temp_cwd() as cwd:
+            with open('foo.py', 'w') as f:
+                s = textwrap.dedent("""
+                    print('The correct file was executed')
+
+                    import os
+                    os.chdir("subdir")
+                """)
+                f.write(s)
+
+            subdir = os.path.join(cwd, 'subdir')
+            os.mkdir(subdir)
+            os.mkdir(os.path.join(subdir, 'subdir'))
+            wrong_file = os.path.join(subdir, 'foo.py')
+
+            with open(wrong_file, 'w') as f:
+                f.write('print("The wrong file was executed")')
+
+            stdout, stderr = self._run_pdb(['foo.py'], 'c\nc\nq')
+            expected = '(Pdb) The correct file was executed'
+            self.assertEqual(stdout.split('\n')[6].rstrip('\r'), expected)
+
 
 def load_tests(*args):
     from test import test_pdb
diff --git a/Misc/NEWS.d/next/Library/2020-11-17-14-30-12.bpo-42383.ubl0Y_.rst b/Misc/NEWS.d/next/Library/2020-11-17-14-30-12.bpo-42383.ubl0Y_.rst
new file mode 100644 (file)
index 0000000..ccf2106
--- /dev/null
@@ -0,0 +1,2 @@
+Fix pdb: previously pdb would fail to restart the debugging target if it was
+specified using a relative path and the current directory changed.