Skip to content

Commit

Permalink
Extract function for _resolve_path.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Apr 21, 2024
1 parent 5ca393b commit 9d26315
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions distutils/spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def _split_path(path: str | None) -> Iterable[str]:
return unique(path.split(os.path.pathsep)) if path else ()


def _search_paths(path):
def _resolve_path(path: str | None) -> str | None:
if path is None:
path = os.environ.get('PATH', None)
# bpo-35755: Don't fall through if PATH is the empty string
Expand All @@ -133,8 +133,11 @@ def _search_paths(path):
except (AttributeError, ValueError):
# os.confstr() or CS_PATH is not available
path = os.defpath
return path


return map(pathlib.Path, _split_path(path))
def _search_paths(path):
return map(pathlib.Path, _split_path(_resolve_path(path)))


def find_executable(executable, path=None):
Expand Down

0 comments on commit 9d26315

Please sign in to comment.