1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

conn,buildah: don't pass bytes to shlex.split (#27896)

* conn,buildah: don't pass bytes to shlex.split on python3
This commit is contained in:
Tomas Tomecek 2017-09-10 02:40:07 +02:00 committed by Toshio Kuratomi
parent 75249e311e
commit 0274835add

View file

@ -46,7 +46,7 @@ import shutil
import subprocess import subprocess
import ansible.constants as C 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 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 """ """ run specified command in a running OCI container using buildah """
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable) super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
cmd_bytes = to_bytes(cmd, errors='surrogate_or_strict') # 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(cmd_bytes) cmd_args_list = shlex.split(to_native(cmd, errors='surrogate_or_strict'))
rc, stdout, stderr = self._buildah("run", cmd_args_list) rc, stdout, stderr = self._buildah("run", cmd_args_list)