From 7f73883fc538f81306ca87e4e7bda89fd6554756 Mon Sep 17 00:00:00 2001 From: Louis Bouchard Date: Thu, 1 Oct 2015 12:53:10 +0200 Subject: [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 --- sos/archive.py | 2 ++ 1 file changed, 2 insertions(+) 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: -- cgit