bpo-34530: Fix distutils find_executable() (GH-9049) (GH-9058)
distutils.spawn.find_executable() now falls back on os.defpath if the
PATH environment variable is not set.
(cherry picked from commit 39487196c87e28128ea907a0d9b8a88ba53f68d5)
diff --git a/Lib/distutils/spawn.py b/Lib/distutils/spawn.py
index 321344a..737b293 100644
--- a/Lib/distutils/spawn.py
+++ b/Lib/distutils/spawn.py
@@ -208,7 +208,8 @@
os.environ['PATH']. Returns the complete filename or None if not found.
"""
if path is None:
- path = os.environ['PATH']
+ path = os.environ.get('PATH', os.defpath)
+
paths = path.split(os.pathsep)
base, ext = os.path.splitext(executable)