summaryrefslogtreecommitdiffstats
path: root/Lib/shutil.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2013-04-16 15:05:03 (GMT)
committerBarry Warsaw <barry@python.org>2013-04-16 15:05:03 (GMT)
commit618738b921d9b3fa1f54304dd18236b3d465fbf8 (patch)
treec67ddc91545260b661eb170a58c0ba03668ec9af /Lib/shutil.py
parent51ce29c530f598d306de27724875cf37007422fc (diff)
downloadcpython-618738b921d9b3fa1f54304dd18236b3d465fbf8.zip
cpython-618738b921d9b3fa1f54304dd18236b3d465fbf8.tar.gz
cpython-618738b921d9b3fa1f54304dd18236b3d465fbf8.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.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/shutil.py b/Lib/shutil.py
index a188408..3904f43 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -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.