From 855651b07a57bcdd3ff8260d2432847472f6db15 Mon Sep 17 00:00:00 2001 From: anthony sottile Date: Thu, 22 May 2025 18:04:32 -0400 Subject: [PATCH 1/3] ensure remote pdb script is readable --- Lib/pdb.py | 3 +++ .../Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst | 1 + 2 files changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst diff --git a/Lib/pdb.py b/Lib/pdb.py index 78ee35f61bbcea..fc83728fb6dc94 100644 --- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -75,6 +75,7 @@ import code import glob import json +import stat import token import types import atexit @@ -3418,6 +3419,8 @@ def attach(pid, commands=()): ) ) connect_script.close() + orig_mode = os.stat(connect_script.name).st_mode + os.chmod(connect_script.name, orig_mode | stat.S_IROTH | stat.S_IRGRP) sys.remote_exec(pid, connect_script.name) # TODO Add a timeout? Or don't bother since the user can ^C? diff --git a/Misc/NEWS.d/next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst b/Misc/NEWS.d/next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst new file mode 100644 index 00000000000000..5c2cba10e12b19 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst @@ -0,0 +1 @@ +Fix ``PermissionError`` when reading remote exec script from ``-m pdb -p``. From 72a1783f81372ec72373cb2fefa19737ad093bb2 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 23 May 2025 16:26:12 -0400 Subject: [PATCH 2/3] Update 2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst --- .../next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst b/Misc/NEWS.d/next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst index 5c2cba10e12b19..a1c7bdc12059da 100644 --- a/Misc/NEWS.d/next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst +++ b/Misc/NEWS.d/next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst @@ -1 +1 @@ -Fix ``PermissionError`` when reading remote exec script from ``-m pdb -p``. +Ensure :func:`pdb.attach` script is readable by remote Python process. From 8b86b959362cabd88f3ee4edf2429e3b46f41e28 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 23 May 2025 16:57:20 -0400 Subject: [PATCH 3/3] Update Misc/NEWS.d/next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst Co-authored-by: Emma Smith --- .../next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst b/Misc/NEWS.d/next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst index a1c7bdc12059da..eea897f59181c9 100644 --- a/Misc/NEWS.d/next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst +++ b/Misc/NEWS.d/next/Library/2025-05-22-18-14-13.gh-issue-134546.fjLVzK.rst @@ -1 +1 @@ -Ensure :func:`pdb.attach` script is readable by remote Python process. +Ensure :mod:`pdb` remote debugging script is readable by remote Python process.