summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins/connection/jail.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/plugins/connection/jail.py')
-rw-r--r--lib/ansible/plugins/connection/jail.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/ansible/plugins/connection/jail.py b/lib/ansible/plugins/connection/jail.py
index ac2cdf9891..93936a0a78 100644
--- a/lib/ansible/plugins/connection/jail.py
+++ b/lib/ansible/plugins/connection/jail.py
@@ -27,10 +27,9 @@ import pipes
import subprocess
import traceback
-from ansible import constants as C
from ansible.errors import AnsibleError
+from ansible.module_utils._text import to_bytes
from ansible.plugins.connection import ConnectionBase, BUFSIZE
-from ansible.utils.unicode import to_bytes
try:
from __main__ import display
@@ -117,7 +116,7 @@ class Connection(ConnectionBase):
local_cmd += [self.jail, self._play_context.executable, '-c', set_env + cmd]
display.vvv("EXEC %s" % (local_cmd,), host=self.jail)
- local_cmd = [to_bytes(i, errors='strict') for i in local_cmd]
+ local_cmd = [to_bytes(i, errors='surrogate_or_strict') for i in local_cmd]
p = subprocess.Popen(local_cmd, shell=False, stdin=stdin,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -153,7 +152,7 @@ class Connection(ConnectionBase):
out_path = pipes.quote(self._prefix_login_path(out_path))
try:
- with open(to_bytes(in_path, errors='strict'), 'rb') as in_file:
+ with open(to_bytes(in_path, errors='surrogate_or_strict'), 'rb') as in_file:
try:
p = self._buffered_exec_command('dd of=%s bs=%s' % (out_path, BUFSIZE), stdin=in_file)
except OSError:
@@ -179,7 +178,7 @@ class Connection(ConnectionBase):
except OSError:
raise AnsibleError("jail connection requires dd command in the jail")
- with open(to_bytes(out_path, errors='strict'), 'wb+') as out_file:
+ with open(to_bytes(out_path, errors='surrogate_or_strict'), 'wb+') as out_file:
try:
chunk = p.stdout.read(BUFSIZE)
while chunk: