mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-108791: Fix pdb
CLI invalid argument handling (#108816)
This commit is contained in:
parent
b75186f69e
commit
162213f2db
3 changed files with 24 additions and 2 deletions
|
@ -138,6 +138,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)
|
||||
|
@ -164,6 +167,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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue