aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Bouchard <louis.bouchard@canonical.com>2015-10-01 12:53:10 +0200
committerBryn M. Reeves <bmr@redhat.com>2015-10-15 12:04:26 +0100
commit7f73883fc538f81306ca87e4e7bda89fd6554756 (patch)
tree4aab22fba30752f74aaf14b1786e80d6aed93835
parent30402b9acd8812176da6d88aed119d8e5bbb9121 (diff)
downloadsos-7f73883fc538f81306ca87e4e7bda89fd6554756.tar.gz
[archive] Force decoding if content is bytes
When content is coming from the output of the tail() method, it is a bytes in python3 and a string in python2. Force the bytes value to be decoded otherwise the later write() function will fail and nothing will be written to the file. Conditional decoding is necessary as the strings in python3 do not have a decode method. Closes #586 Signed-off-by: Louis Bouchard <louis.bouchard@canonical.com>
-rw-r--r--sos/archive.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/sos/archive.py b/sos/archive.py
index 10fa7609..0336aabe 100644
--- a/sos/archive.py
+++ b/sos/archive.py
@@ -180,6 +180,8 @@ class FileCacheArchive(Archive):
dest = self.dest_path(dest)
self._check_path(dest)
f = codecs.open(dest, 'w', encoding='utf-8')
+ if isinstance(content, bytes):
+ content = content.decode('utf8', 'ignore')
f.write(content)
if os.path.exists(src):
try: