diff options
author | Barry Warsaw <barry@python.org> | 2013-04-16 15:18:18 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2013-04-16 15:18:18 (GMT) |
commit | ecaefcf44eca8a77946a4d2cc390b6d782647bfc (patch) | |
tree | efcde9deb4f4d7eed790a8dc32d601eb8c6f64cf /Lib/shutil.py | |
parent | 7c5e094cbfa6769bf4cabfa5f883f2dc5320667b (diff) | |
parent | 618738b921d9b3fa1f54304dd18236b3d465fbf8 (diff) | |
download | cpython-ecaefcf44eca8a77946a4d2cc390b6d782647bfc.zip cpython-ecaefcf44eca8a77946a4d2cc390b6d782647bfc.tar.gz cpython-ecaefcf44eca8a77946a4d2cc390b6d782647bfc.tar.bz2 |
- Issue #17012: shutil.which() no longer fallbacks to the PATH environment
variable if empty path argument is specified. Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/shutil.py')
-rw-r--r-- | Lib/shutil.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py index c2f0278..6879d8b 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -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. |