- 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:
Barry Warsaw 2013-04-16 11:18:18 -04:00
commit ecaefcf44e
3 changed files with 29 additions and 1 deletions

View file

@ -1090,7 +1090,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.