mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-140741: Fix profiling.sampling handling of error raised by target (#140745)
This commit is contained in:
parent
02202c117b
commit
d3aa5f689c
3 changed files with 23 additions and 4 deletions
|
|
@ -175,14 +175,15 @@ def _execute_script(script_path: str, script_args: List[str], cwd: str) -> None:
|
|||
try:
|
||||
with open(script_path, 'rb') as f:
|
||||
source_code = f.read()
|
||||
|
||||
# Compile and execute the script
|
||||
code = compile(source_code, script_path, 'exec')
|
||||
exec(code, {'__name__': '__main__', '__file__': script_path})
|
||||
except FileNotFoundError as e:
|
||||
raise TargetError(f"Script file not found: {script_path}") from e
|
||||
except PermissionError as e:
|
||||
raise TargetError(f"Permission denied reading script: {script_path}") from e
|
||||
|
||||
try:
|
||||
# Compile and execute the script
|
||||
code = compile(source_code, script_path, 'exec')
|
||||
exec(code, {'__name__': '__main__', '__file__': script_path})
|
||||
except SyntaxError as e:
|
||||
raise TargetError(f"Syntax error in script {script_path}: {e}") from e
|
||||
except SystemExit:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue