diff --git a/changelogs/fragments/438-docker-py.yml b/changelogs/fragments/438-docker-py.yml new file mode 100644 index 000000000..4b0aa4ef9 --- /dev/null +++ b/changelogs/fragments/438-docker-py.yml @@ -0,0 +1,2 @@ +minor_changes: + - "modules and plugins communicating directly with the Docker daemon - simplify use of helper function that was removed in Docker SDK for Python to find executables (https://github.com/ansible-collections/community.docker/pull/438)." diff --git a/plugins/module_utils/_api/credentials/utils.py b/plugins/module_utils/_api/credentials/utils.py index 08699efb3..1ab84fe5b 100644 --- a/plugins/module_utils/_api/credentials/utils.py +++ b/plugins/module_utils/_api/credentials/utils.py @@ -26,11 +26,14 @@ def find_executable(executable, path=None): As distutils.spawn.find_executable, but on Windows, look up every extension declared in PATHEXT instead of just `.exe` """ + if not PY2: + # shutil.which() already uses PATHEXT on Windows, so on + # Python 3 we can simply use shutil.which() in all cases. + # (https://github.com/docker/docker-py/commit/42789818bed5d86b487a030e2e60b02bf0cfa284) + return which(executable, path=path) + if sys.platform != 'win32': - if PY2: - return which(executable, path) - else: - return which(executable, path=path) + return which(executable, path) if path is None: path = os.environ['PATH']