diff options
author | Tian Gao <gaogaotiantian@hotmail.com> | 2023-11-27 23:11:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-27 23:11:40 (GMT) |
commit | b90a5cf11cdb69e60aed7be732e80113bca7bbe4 (patch) | |
tree | 2b6c903d11ec948baf80ba163f01978189a72b5b /Lib/pdb.py | |
parent | 8f71b349de1ff2b11223ff7a8241c62a5a932339 (diff) | |
download | cpython-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-x | Lib/pdb.py | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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): |