diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2014-09-18 15:04:32 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2014-09-18 15:04:32 +0100 |
commit | 4e2f91a4931b7cfe9b0c4a945f71de00186b3892 (patch) | |
tree | 534cb73ccce3541cdcca0d9c58febe77665a9be2 | |
parent | 92b1d4a9e79b56c722a60687b58ae1302a7cf718 (diff) | |
download | sos-4e2f91a4931b7cfe9b0c4a945f71de00186b3892.tar.gz |
[utilities] do not pass unicode to shlex on PY2 runtimes
Running sos-3.2beta on a python2.6 runtime leads to:
File "/usr/sbin/sosreport", line 25, in <module>
main(sys.argv[1:])
File "/usr/lib/python2.6/site-packages/sos/sosreport.py", line 1408, in main
sos.execute()
TypeError: execve() argument 1 must be encoded string without NULL bytes, not str
> /usr/lib64/python2.6/subprocess.py(1234)_execute_child()
-> raise child_exception
This occurs because some command output is interpreted as unicode
by the Python runtime. When this output is processed in a plugin
and passed back down to sos_get_command_output() it leads to the
above exception.
Work around the problem by encoding strings passed to shlex.split
on older Python versions.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/utilities.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sos/utilities.py b/sos/utilities.py index 4dffe695..7c067811 100644 --- a/sos/utilities.py +++ b/sos/utilities.py @@ -138,6 +138,9 @@ def sos_get_command_output(command, timeout=300, runat=None): if timeout and is_executable("timeout"): command = "timeout %ds %s" % (timeout, command) + # shlex.split() reacts badly to unicode on older python runtimes. + if six.PY2: + command = command.encode('utf-8') args = shlex.split(command) try: p = Popen(args, shell=False, stdout=PIPE, stderr=STDOUT, |