Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Extract method for replacing sys_path, and isolate realpath u…
…sage there."

This reverts commit 855aac3.
  • Loading branch information
jaraco committed Dec 8, 2025
commit 03eae7e0f269d6937946c6bc88f45e6b626e4bb9
15 changes: 6 additions & 9 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,13 @@ class _ExecutableTarget:

class _ScriptTarget(_ExecutableTarget):
def __init__(self, target):
self._target = target
self._check(target)
self._replace_sys_path(target)
self._target = os.path.realpath(target)

# If PYTHONSAFEPATH (-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._target)

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

@staticmethod
def _replace_sys_path(target):
# If PYTHONSAFEPATH (-P) is not set, sys.path[0] is the directory
# of pdb, so replace it with the directory of the script
if not sys.flags.safe_path:
sys.path[0] = os.path.dirname(os.path.realpath(target))

def __repr__(self):
return self._target

Expand Down
Loading