Ignore unicode decode errors in test suite's encoded_file class
authorPavel Labath <pavel@labath.sk>
Sat, 1 Sep 2018 12:15:46 +0000 (12:15 +0000)
committerPavel Labath <pavel@labath.sk>
Sat, 1 Sep 2018 12:15:46 +0000 (12:15 +0000)
These happen in a couple of tests when lldb tries to pretty print a
const char * variable in the inferior which points to garbage. Instead,
we have the python replace the invalid sequences with the unicode
replacement character.

llvm-svn: 341274

lldb/packages/Python/lldbsuite/support/encoded_file.py

index 2c2fef3..5c04cce 100644 (file)
@@ -31,7 +31,7 @@ def _encoded_write(old_write, encoding):
         # If we were asked to write a `str` (in Py2) or a `bytes` (in Py3) decode it
         # as unicode before attempting to write.
         if isinstance(s, six.binary_type):
-            s = s.decode(encoding)
+            s = s.decode(encoding, "replace")
         return old_write(s)
     return impl