summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Bienkowski <hexagonrecursion@gmail.com>2021-01-25 21:08:01 (GMT)
committerGitHub <noreply@github.com>2021-01-25 21:08:01 (GMT)
commit501d4a51e32c7bbba255598adc307660b5af891a (patch)
tree56cd9aa1e08b74b58128683daa35a2d5313dfda2
parentf066bd94b9225a5a3c4ade5fc3ff81e3c49b7b32 (diff)
downloadcpython-501d4a51e32c7bbba255598adc307660b5af891a.zip
cpython-501d4a51e32c7bbba255598adc307660b5af891a.tar.gz
cpython-501d4a51e32c7bbba255598adc307660b5af891a.tar.bz2
bpo-42383: pdb: do not fail to restart the target if the current directory changed (#23412)
This commit only adds tests and a news entry. The actual bug was fixed in the earlier commit.
-rw-r--r--Lib/test/test_pdb.py23
-rw-r--r--Misc/NEWS.d/next/Library/2020-11-17-14-30-12.bpo-42383.ubl0Y_.rst2
2 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 0a6f186..51cd378 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -1703,6 +1703,29 @@ def bœr():
self.assertEqual(stdout.split('\n')[2].rstrip('\r'), expected)
+ def test_issue42383(self):
+ with os_helper.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
index 0000000..ccf2106
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-11-17-14-30-12.bpo-42383.ubl0Y_.rst
@@ -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.