summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pdb.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2021-07-28 01:51:42 (GMT)
committerGitHub <noreply@github.com>2021-07-28 01:51:42 (GMT)
commitee03bad25e83b00ba5fc2a0265b48c6286e6b3f7 (patch)
tree158d1626a8fe583ee120147abbc649a4e7d21a0a /Lib/test/test_pdb.py
parent38ddc8beb38d9a685de296a58b0741850e4853e5 (diff)
downloadcpython-ee03bad25e83b00ba5fc2a0265b48c6286e6b3f7.zip
cpython-ee03bad25e83b00ba5fc2a0265b48c6286e6b3f7.tar.gz
cpython-ee03bad25e83b00ba5fc2a0265b48c6286e6b3f7.tar.bz2
bpo-44461: Check early that a pdb target is valid for execution. (#27227)
* bpo-44461: Fix bug with pdb's handling of import error due to a package which does not have a __main__ module * 📜🀖 Added by blurb_it. * remove "else" Co-authored-by: Jason R. Coombs <jaraco@jaraco.com> * If running as a module, first check that it can run as a module. Alternate fix for bpo-44461. Co-authored-by: Irit Katriel <iritkatriel@yahoo.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_pdb.py')
-rw-r--r--Lib/test/test_pdb.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 5fe7517..5794e67 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -1729,6 +1729,20 @@ def bœr():
self.assertIn("ImportError: No module named t_main.__main__",
stdout.splitlines())
+ def test_package_without_a_main(self):
+ pkg_name = 't_pkg'
+ module_name = 't_main'
+ os_helper.rmtree(pkg_name)
+ modpath = pkg_name + '/' + module_name
+ os.makedirs(modpath)
+ with open(modpath + '/__init__.py', 'w') as f:
+ pass
+ self.addCleanup(os_helper.rmtree, pkg_name)
+ stdout, stderr = self._run_pdb(['-m', modpath.replace('/', '.')], "")
+ self.assertIn(
+ "'t_pkg.t_main' is a package and cannot be directly executed",
+ stdout)
+
def test_blocks_at_first_code_line(self):
script = """
#This is a comment, on line 2