Skip to content

Commit bbb539e

Browse files
committed
Handle RuntimeError when attaching to a process in pdb.py
Signed-off-by: Frost Ming <[email protected]>
1 parent 1e1f435 commit bbb539e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Lib/pdb.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3577,6 +3577,11 @@ def main():
35773577
parser.error("argument -m: not allowed with argument --pid")
35783578
try:
35793579
attach(opts.pid, opts.commands)
3580+
except RuntimeError as e:
3581+
while e.__context__ is not None:
3582+
e = e.__context__
3583+
print(f"Error attaching to process: {e}")
3584+
sys.exit(1)
35803585
except PermissionError as e:
35813586
exit_with_permission_help_text()
35823587
return

0 commit comments

Comments
 (0)