Skip to content

[3.8] bpo-42383: pdb: do not fail to restart the target if the current directory changed (GH-23412) #24323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,29 @@ def test_issue42384_symlink(self):

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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.