Skip to content

Commit 501d4a5

Browse files
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.
1 parent f066bd9 commit 501d4a5

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Lib/test/test_pdb.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,29 @@ def test_issue42384_symlink(self):
17031703

17041704
self.assertEqual(stdout.split('\n')[2].rstrip('\r'), expected)
17051705

1706+
def test_issue42383(self):
1707+
with os_helper.temp_cwd() as cwd:
1708+
with open('foo.py', 'w') as f:
1709+
s = textwrap.dedent("""
1710+
print('The correct file was executed')
1711+
1712+
import os
1713+
os.chdir("subdir")
1714+
""")
1715+
f.write(s)
1716+
1717+
subdir = os.path.join(cwd, 'subdir')
1718+
os.mkdir(subdir)
1719+
os.mkdir(os.path.join(subdir, 'subdir'))
1720+
wrong_file = os.path.join(subdir, 'foo.py')
1721+
1722+
with open(wrong_file, 'w') as f:
1723+
f.write('print("The wrong file was executed")')
1724+
1725+
stdout, stderr = self._run_pdb(['foo.py'], 'c\nc\nq')
1726+
expected = '(Pdb) The correct file was executed'
1727+
self.assertEqual(stdout.split('\n')[6].rstrip('\r'), expected)
1728+
17061729

17071730
def load_tests(*args):
17081731
from test import test_pdb
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix pdb: previously pdb would fail to restart the debugging target if it was
2+
specified using a relative path and the current directory changed.

0 commit comments

Comments
 (0)