mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
- Issue #17012: shutil.which() no longer fallbacks to the PATH environment
variable if empty path argument is specified. Patch by Serhiy Storchaka.
This commit is contained in:
parent
51ce29c530
commit
618738b921
3 changed files with 29 additions and 1 deletions
|
@ -1091,7 +1091,11 @@ def which(cmd, mode=os.F_OK | os.X_OK, path=None):
|
|||
return cmd
|
||||
return None
|
||||
|
||||
path = (path or os.environ.get("PATH", os.defpath)).split(os.pathsep)
|
||||
if path is None:
|
||||
path = os.environ.get("PATH", os.defpath)
|
||||
if not path:
|
||||
return None
|
||||
path = path.split(os.pathsep)
|
||||
|
||||
if sys.platform == "win32":
|
||||
# The current directory takes precedence on Windows.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue