summaryrefslogtreecommitdiffstats
path: root/Lib/pdb.py
diff options
context:
space:
mode:
authorRadislav Chugunov <52372310+chgnrdv@users.noreply.github.com>2023-10-19 13:26:40 (GMT)
committerGitHub <noreply@github.com>2023-10-19 13:26:40 (GMT)
commit26a028269b807d599ea2f5fa266fccfd1421775b (patch)
tree3ca3f6f9e8f26a1077804bc6d09238e6d81a131d /Lib/pdb.py
parent2258d6cfa2fcd0c290328e81b68aff25abf8c3d8 (diff)
downloadcpython-26a028269b807d599ea2f5fa266fccfd1421775b.zip
cpython-26a028269b807d599ea2f5fa266fccfd1421775b.tar.gz
cpython-26a028269b807d599ea2f5fa266fccfd1421775b.tar.bz2
[3.11] gh-108791: Fix pdb CLI invalid argument handling (GH-108816) (#111063)
* [3.11] gh-108791: Fix `pdb` CLI invalid argument handling (GH-108816) (cherry picked from commit 162213f2db3835e1115178d38741544f4b4db416) Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
Diffstat (limited to 'Lib/pdb.py')
-rwxr-xr-xLib/pdb.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 5dfe507..4a4a0b9 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -136,6 +136,9 @@ class _ScriptTarget(str):
if not os.path.exists(self):
print('Error:', self.orig, 'does not exist')
sys.exit(1)
+ if os.path.isdir(self):
+ print('Error:', self.orig, 'is a directory')
+ sys.exit(1)
# Replace pdb's dir with script's dir in front of module search path.
sys.path[0] = os.path.dirname(self)
@@ -162,6 +165,9 @@ class _ModuleTarget(str):
def check(self):
try:
self._details
+ except ImportError as e:
+ print(f"ImportError: {e}")
+ sys.exit(1)
except Exception:
traceback.print_exc()
sys.exit(1)