We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b3b6fff commit 00ef823Copy full SHA for 00ef823
Lib/profiling/sampling/cli.py
@@ -614,9 +614,14 @@ def _handle_attach(args):
614
615
def _handle_run(args):
616
"""Handle the 'run' command."""
617
- # Validate script exists (only for scripts, not modules)
618
- if not args.module and not os.path.exists(args.target):
619
- sys.exit(f"Error: script not found: {args.target}")
+ # Validate target exists before launching
+ if args.module:
+ import importlib.util
620
+ if importlib.util.find_spec(args.target) is None:
621
+ sys.exit(f"Error: module not found: {args.target}")
622
+ else:
623
+ if not os.path.exists(args.target):
624
+ sys.exit(f"Error: script not found: {args.target}")
625
626
# Check if live mode is requested
627
if args.live:
0 commit comments