Skip to content
Next Next commit
Handle RuntimeError when attaching to a process in pdb.py
Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming committed Oct 15, 2025
commit bbb539e0794fa66249f00cd8b7c1be2631092389
5 changes: 5 additions & 0 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3577,6 +3577,11 @@ def main():
parser.error("argument -m: not allowed with argument --pid")
try:
attach(opts.pid, opts.commands)
except RuntimeError as e:
while e.__context__ is not None:
e = e.__context__
print(f"Error attaching to process: {e}")
sys.exit(1)
except PermissionError as e:
exit_with_permission_help_text()
return
Expand Down