Skip to content

Commit 03eae7e

Browse files
committed
Revert "Extract method for replacing sys_path, and isolate realpath usage there."
This reverts commit 855aac3.
1 parent 855aac3 commit 03eae7e

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

Lib/pdb.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,13 @@ class _ExecutableTarget:
183183

184184
class _ScriptTarget(_ExecutableTarget):
185185
def __init__(self, target):
186-
self._target = target
187186
self._check(target)
188-
self._replace_sys_path(target)
187+
self._target = os.path.realpath(target)
188+
189+
# If PYTHONSAFEPATH (-P) is not set, sys.path[0] is the directory
190+
# of pdb, and we should replace it with the directory of the script
191+
if not sys.flags.safe_path:
192+
sys.path[0] = os.path.dirname(self._target)
189193

190194
@staticmethod
191195
def _check(target):
@@ -199,13 +203,6 @@ def _check(target):
199203
print(f'Error: {target} is a directory')
200204
sys.exit(1)
201205

202-
@staticmethod
203-
def _replace_sys_path(target):
204-
# If PYTHONSAFEPATH (-P) is not set, sys.path[0] is the directory
205-
# of pdb, so replace it with the directory of the script
206-
if not sys.flags.safe_path:
207-
sys.path[0] = os.path.dirname(os.path.realpath(target))
208-
209206
def __repr__(self):
210207
return self._target
211208

0 commit comments

Comments
 (0)