8000 [3.9] bpo-42383: pdb: do not fail to restart the target if the curren… · python/cpython@f8cfe54 · GitHub
[go: up one dir, main page]

Skip to content

Commit f8cfe54

Browse files
[3.9] bpo-42383: pdb: do not fail to restart the target if the current directory changed (GH-23412) (#24322)
1 parent f2df795 commit f8cfe54

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
@@ -1702,6 +1702,29 @@ def test_issue42384_symlink(self):
17021702

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

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

17061729
def load_tests(*args):
17071730
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)
0