summaryrefslogtreecommitdiffstats
path: root/Lib/pdb.py
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2023-11-27 23:11:40 (GMT)
committerGitHub <noreply@github.com>2023-11-27 23:11:40 (GMT)
commitb90a5cf11cdb69e60aed7be732e80113bca7bbe4 (patch)
tree2b6c903d11ec948baf80ba163f01978189a72b5b /Lib/pdb.py
parent8f71b349de1ff2b11223ff7a8241c62a5a932339 (diff)
downloadcpython-b90a5cf11cdb69e60aed7be732e80113bca7bbe4.zip
cpython-b90a5cf11cdb69e60aed7be732e80113bca7bbe4.tar.gz
cpython-b90a5cf11cdb69e60aed7be732e80113bca7bbe4.tar.bz2
gh-99367: Do not mangle sys.path[0] in pdb if safe_path is set (#111762)
Co-authored-by: Christian Walther <cwalther@users.noreply.github.com>
Diffstat (limited to 'Lib/pdb.py')
-rwxr-xr-xLib/pdb.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index ed78d74..9d12418 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -142,8 +142,10 @@ class _ScriptTarget(str):
print('Error:', self.orig, 'is a directory')
sys.exit(1)
- # Replace pdb's dir with script's dir in front of module search path.
- sys.path[0] = os.path.dirname(self)
+ # If safe_path(-P) is not set, sys.path[0] is the directory
+ # of pdb, and we should replace it with the directory of the script
+ if not sys.flags.safe_path:
+ sys.path[0] = os.path.dirname(self)
@property
def filename(self):