diff options
author | Martin Krizek <martin.krizek@gmail.com> | 2019-04-17 09:13:53 +0200 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2019-04-22 10:04:28 -0700 |
commit | 44b3f967bff925245b84224bcb182d30309c6fa1 (patch) | |
tree | f581714c187fa295b848625c9a9af41c7930ef94 | |
parent | ab725bb86ef9cbd109fdf0ebac3812ef696e396b (diff) | |
download | ansible-44b3f967bff925245b84224bcb182d30309c6fa1.tar.gz |
ansible-test yamllint: fix UnicodeDecodeError (#55364)
* ansible-test yamllint: fix UnicodeDecodeError
* Conditional fix
(cherry picked from commit f8bebc61c8e176f8ebde9743a59b162d1df6ae6a)
-rw-r--r-- | test/runner/lib/util.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/test/runner/lib/util.py b/test/runner/lib/util.py index 11d3365412..b6571b7614 100644 --- a/test/runner/lib/util.py +++ b/test/runner/lib/util.py @@ -385,7 +385,10 @@ def raw_command(cmd, capture=False, env=None, data=None, cwd=None, explain=False if communicate: encoding = 'utf-8' - data_bytes = data.encode(encoding, 'surrogateescape') if data else None + if data is None or isinstance(data, bytes): + data_bytes = data + else: + data_bytes = data.encode(encoding, 'surrogateescape') stdout_bytes, stderr_bytes = process.communicate(data_bytes) stdout_text = stdout_bytes.decode(encoding, str_errors) if stdout_bytes else u'' stderr_text = stderr_bytes.decode(encoding, str_errors) if stderr_bytes else u'' |