Blame SOURCES/0021-global-make-all-utf-8-handling-use-errors-ignore.patch

0cd6dc
From 348ed379209aacfe6c1f870a3a68e06b39a51f06 Mon Sep 17 00:00:00 2001
0cd6dc
From: "Bryn M. Reeves" <bmr@redhat.com>
0cd6dc
Date: Tue, 9 Dec 2014 17:30:06 +0000
0cd6dc
Subject: [PATCH 21/93] [global] make all utf-8 handling use errors='ignore'
0cd6dc
0cd6dc
Stop playing whack-a-mole with unicode handling and ignore all
0cd6dc
invalid characters. It's not really possible to ensure that we
0cd6dc
always get strict utf-8 data from the system - e.g. dmesg on
0cd6dc
systems with broken BIOS strings will often spit undecodable
0cd6dc
byte sequences.
0cd6dc
0cd6dc
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
0cd6dc
---
0cd6dc
 sos/archive.py          | 4 ++--
0cd6dc
 sos/plugins/__init__.py | 5 +++--
0cd6dc
 sos/utilities.py        | 7 +++++--
0cd6dc
 3 files changed, 10 insertions(+), 6 deletions(-)
0cd6dc
0cd6dc
diff --git a/sos/archive.py b/sos/archive.py
0cd6dc
index 6063625..0e019bf 100644
0cd6dc
--- a/sos/archive.py
0cd6dc
+++ b/sos/archive.py
0cd6dc
@@ -406,9 +406,9 @@ class TarFileArchive(FileCacheArchive):
0cd6dc
                           close_fds=True)
0cd6dc
                 stdout, stderr = p.communicate()
0cd6dc
                 if stdout:
0cd6dc
-                    self.log_info(stdout.decode('utf-8'))
0cd6dc
+                    self.log_info(stdout.decode('utf-8', 'ignore'))
0cd6dc
                 if stderr:
0cd6dc
-                    self.log_error(stderr.decode('utf-8'))
0cd6dc
+                    self.log_error(stderr.decode('utf-8', 'ignore'))
0cd6dc
                 self._suffix += suffix
0cd6dc
                 return self.name()
0cd6dc
             except Exception as e:
0cd6dc
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
0cd6dc
index b289144..4fd85be 100644
0cd6dc
--- a/sos/plugins/__init__.py
0cd6dc
+++ b/sos/plugins/__init__.py
0cd6dc
@@ -542,7 +542,7 @@ class Plugin(object):
0cd6dc
     def add_string_as_file(self, content, filename):
0cd6dc
         """Add a string to the archive as a file named `filename`"""
0cd6dc
         self.copy_strings.append((content, filename))
0cd6dc
-        content = "..." + (content.splitlines()[0]).decode('utf8')
0cd6dc
+        content = "..." + (content.splitlines()[0]).decode('utf8', 'ignore')
0cd6dc
         self._log_debug("added string '%s' as '%s'" % (content, filename))
0cd6dc
 
0cd6dc
     def get_cmd_output_now(self, exe, suggest_filename=None,
0cd6dc
@@ -611,7 +611,8 @@ class Plugin(object):
0cd6dc
 
0cd6dc
     def _collect_strings(self):
0cd6dc
         for string, file_name in self.copy_strings:
0cd6dc
-            content = "..." + (string.splitlines()[0]).decode('utf8')
0cd6dc
+            content = "..."
0cd6dc
+            content += (string.splitlines()[0]).decode('utf8', 'ignore')
0cd6dc
             self._log_info("collecting string '%s' as '%s'"
0cd6dc
                            % (content, file_name))
0cd6dc
             try:
0cd6dc
diff --git a/sos/utilities.py b/sos/utilities.py
0cd6dc
index 7e8cd7e..8cb4ed6 100644
0cd6dc
--- a/sos/utilities.py
0cd6dc
+++ b/sos/utilities.py
0cd6dc
@@ -140,7 +140,7 @@ def sos_get_command_output(command, timeout=300, runat=None):
0cd6dc
 
0cd6dc
     # shlex.split() reacts badly to unicode on older python runtimes.
0cd6dc
     if not six.PY3:
0cd6dc
-        command = command.encode('utf-8')
0cd6dc
+        command = command.encode('utf-8', 'ignore')
0cd6dc
     args = shlex.split(command)
0cd6dc
     try:
0cd6dc
         p = Popen(args, shell=False, stdout=PIPE, stderr=STDOUT,
0cd6dc
@@ -159,7 +159,10 @@ def sos_get_command_output(command, timeout=300, runat=None):
0cd6dc
     if p.returncode == 126 or p.returncode == 127:
0cd6dc
         stdout = six.binary_type(b"")
0cd6dc
 
0cd6dc
-    return {'status': p.returncode, 'output': stdout.decode('utf-8')}
0cd6dc
+    return {
0cd6dc
+        'status': p.returncode,
0cd6dc
+        'output': stdout.decode('utf-8', 'ignore')
0cd6dc
+    }
0cd6dc
 
0cd6dc
 
0cd6dc
 def import_module(module_fqname, superclasses=None):
0cd6dc
-- 
0cd6dc
1.9.3
0cd6dc