From a0989d125d60fe49a871d035c6b822f7647045be Mon Sep 17 00:00:00 2001 From: Tomas Tomecek Date: Sun, 10 Sep 2017 02:40:07 +0200 Subject: [PATCH] conn,buildah: don't pass bytes to shlex.split (#27896) * conn,buildah: don't pass bytes to shlex.split on python3 (cherry picked from commit 0274835adde81bd4e148e34f66e4379ba2427a31) --- lib/ansible/plugins/connection/buildah.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/plugins/connection/buildah.py b/lib/ansible/plugins/connection/buildah.py index c210fb6e26..ba634f8c71 100644 --- a/lib/ansible/plugins/connection/buildah.py +++ b/lib/ansible/plugins/connection/buildah.py @@ -46,7 +46,7 @@ import shutil import subprocess import ansible.constants as C -from ansible.module_utils._text import to_bytes +from ansible.module_utils._text import to_bytes, to_native from ansible.plugins.connection import ConnectionBase, ensure_connect @@ -124,8 +124,8 @@ class Connection(ConnectionBase): """ run specified command in a running OCI container using buildah """ super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable) - cmd_bytes = to_bytes(cmd, errors='surrogate_or_strict') - cmd_args_list = shlex.split(cmd_bytes) + # shlex.split has a bug with text strings on Python-2.6 and can only handle text strings on Python-3 + cmd_args_list = shlex.split(to_native(cmd, errors='surrogate_or_strict')) rc, stdout, stderr = self._buildah("run", cmd_args_list)