Skip to content

Commit 3170ece

Browse files
committed
fix: print a user-friendly error message when unable to attach to process
Signed-off-by: Frost Ming <[email protected]>
1 parent c50b200 commit 3170ece

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Lib/pdb.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3577,10 +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 exc:
3581-
while exc.__context__ is not None:
3582-
exc = exc.__context__
3583-
print(f"Error attaching to process: {exc}")
3580+
except RuntimeError:
3581+
print(
3582+
f"Cannot attach to pid {opts.pid}, please make sure that the process exists "
3583+
"and is using the same Python version."
3584+
)
35843585
sys.exit(1)
35853586
except PermissionError:
35863587
exit_with_permission_help_text()

0 commit comments

Comments
 (0)