Skip to content

Commit

Permalink
Refactor _resolve_path to be less nested.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Apr 21, 2024
1 parent 9d26315 commit 66afeb3
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions distutils/spawn.py
Expand Up @@ -124,16 +124,22 @@ def _split_path(path: str | None) -> Iterable[str]:


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
if path is None:
try:
path = os.confstr("CS_PATH")
except (AttributeError, ValueError):
# os.confstr() or CS_PATH is not available
path = os.defpath
return path
"""
Resolve a path from a specified value, or from environmental state.
"""
if path is not None:
return path

env = os.environ.get('PATH', None)
# bpo-35755: Don't fall through if PATH is the empty string
if env is not None:
return env

try:
return os.confstr("CS_PATH")
except (AttributeError, ValueError):
# os.confstr() or CS_PATH is not available
return os.defpath


def _search_paths(path):
Expand Down

0 comments on commit 66afeb3

Please sign in to comment.