summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Bienkowski <hexagonrecursion@gmail.com>2021-01-26 15:58:33 +0000
committerGitHub <noreply@github.com>2021-01-26 07:58:33 -0800
commitd863deeff27f00ac33e9f169d23ca56d69af3f86 (patch)
treec2d377f1efe22ee5965463c026caa53fcf1bc053
parent[3.8] bpo-42384: pdb: correctly populate sys.path[0] (GH-23338) (#24320) (diff)
downloadcpython-d863deeff27f00ac33e9f169d23ca56d69af3f86.tar.gz
cpython-d863deeff27f00ac33e9f169d23ca56d69af3f86.tar.bz2
cpython-d863deeff27f00ac33e9f169d23ca56d69af3f86.zip
[3.8] bpo-42383: pdb: do not fail to restart the target if the current directory changed (GH-23412) (#24323)
-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 74448747e3e..f77c3550774 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -1699,6 +1699,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
index 00000000000..ccf2106f28a
--- /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.