diff --git a/changelogs/fragments/305-docker_compose-errors-warnings.yml b/changelogs/fragments/305-docker_compose-errors-warnings.yml new file mode 100644 index 00000000..0ee0352e --- /dev/null +++ b/changelogs/fragments/305-docker_compose-errors-warnings.yml @@ -0,0 +1,2 @@ +bugfixes: + - "docker_compose - fix Python 3 type error when extracting warnings or errors from docker-compose's output (https://github.com/ansible-collections/community.docker/pull/305)." diff --git a/plugins/modules/docker_compose.py b/plugins/modules/docker_compose.py index 2f692609..e34beeb6 100644 --- a/plugins/modules/docker_compose.py +++ b/plugins/modules/docker_compose.py @@ -587,8 +587,8 @@ def attempt_extract_errors(exc_str, stdout, stderr): msg = 'unknown cause' return { - 'warnings': [w.encode('utf-8') for w in warnings], - 'errors': [e.encode('utf-8') for e in errors], + 'warnings': [to_native(w) for w in warnings], + 'errors': [to_native(e) for e in errors], 'msg': msg, 'module_stderr': ''.join(stderr), 'module_stdout': ''.join(stdout)