]> granicus.if.org Git - python/commit
bpo-35755: shutil.which() uses os.confstr("CS_PATH") (GH-12858)
authorVictor Stinner <vstinner@redhat.com>
Wed, 17 Apr 2019 14:26:36 +0000 (16:26 +0200)
committerGitHub <noreply@github.com>
Wed, 17 Apr 2019 14:26:36 +0000 (16:26 +0200)
commit228a3c99bdb2d02771bead66a0beabafad3a90d3
tree40ff4e1063f1205ad1f32f9005ba3675531c19a4
parent71ce03df9c643faa94fbdf73bbb4e99a9a62cbdc
bpo-35755: shutil.which() uses os.confstr("CS_PATH") (GH-12858)

shutil.which() and distutils.spawn.find_executable() now use
os.confstr("CS_PATH") if available instead of os.defpath, if the PATH
environment variable is not set.

Don't use os.confstr("CS_PATH") nor os.defpath if the PATH
environment variable is set to an empty string to mimick Unix 'which'
command behavior.

Changes:

* find_executable() now starts by checking for the executable in the
  current working directly case. Add an explicit
  "if not path: return None".
* Add tests for PATH='' (empty string), PATH=':' and for PATHEXT.
Lib/distutils/spawn.py
Lib/distutils/tests/test_spawn.py
Lib/shutil.py
Lib/test/test_shutil.py
Misc/NEWS.d/next/Library/2019-04-16-17-50-39.bpo-35755.Fg4EXb.rst [new file with mode: 0644]