From 7e8d9081a7de9eb1a57a8335fd96f5828363d090 Mon Sep 17 00:00:00 2001 From: Matthias Fuchs Date: Sat, 3 Nov 2018 21:58:03 +0100 Subject: [PATCH] Make the flatpak module work with Python 3. Fixes #46994 Fixes #46995 --- lib/ansible/modules/packaging/os/flatpak.py | 3 ++- lib/ansible/modules/packaging/os/flatpak_remote.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/packaging/os/flatpak.py b/lib/ansible/modules/packaging/os/flatpak.py index 42de3b8235..b8ee51efd9 100644 --- a/lib/ansible/modules/packaging/os/flatpak.py +++ b/lib/ansible/modules/packaging/os/flatpak.py @@ -127,6 +127,7 @@ stdout: import subprocess from ansible.module_utils.six.moves.urllib.parse import urlparse from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils._text import to_native def install_flat(module, binary, remote, name, method): @@ -203,7 +204,7 @@ def _flatpak_command(module, noop, command): result['stderr'] = stderr_data if result['rc'] != 0: module.fail_json(msg="Failed to execute flatpak command", **result) - return stdout_data + return to_native(stdout_data) def main(): diff --git a/lib/ansible/modules/packaging/os/flatpak_remote.py b/lib/ansible/modules/packaging/os/flatpak_remote.py index 8425e1b219..fa0aa19abf 100644 --- a/lib/ansible/modules/packaging/os/flatpak_remote.py +++ b/lib/ansible/modules/packaging/os/flatpak_remote.py @@ -120,6 +120,7 @@ stdout: import subprocess from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils._text import to_bytes, to_native def add_remote(module, binary, name, flatpakrepo_url, method): @@ -168,7 +169,7 @@ def _flatpak_command(module, noop, command): result['stderr'] = stderr_data if result['rc'] != 0: module.fail_json(msg="Failed to execute flatpak command", **result) - return stdout_data + return to_native(stdout_data) def main(): @@ -205,7 +206,7 @@ def main(): if not binary: module.fail_json(msg="Executable '%s' was not found on the system." % executable, **result) - remote_already_exists = remote_exists(module, binary, bytes(name, 'utf-8'), method) + remote_already_exists = remote_exists(module, binary, to_bytes(name), method) if state == 'present' and not remote_already_exists: add_remote(module, binary, name, flatpakrepo_url, method)