[testsuite] Drop characters that can't be decoded, restoring parity with Py2.
authorDavide Italiano <davide@freebsd.org>
Thu, 7 Mar 2019 17:45:53 +0000 (17:45 +0000)
committerDavide Italiano <davide@freebsd.org>
Thu, 7 Mar 2019 17:45:53 +0000 (17:45 +0000)
Tests that check the output of `memory find` may trip over
unreadable characters, and in Python 3 this is an error.

llvm-svn: 355612

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

index 1b4c7a2e48db774b35b0bc2878263ee14a689482..c233e046ba757dc59e76e9e77860e51fc1a8b12d 100644 (file)
@@ -31,6 +31,9 @@ def _encoded_write(old_write, encoding):
         # as unicode before attempting to write.
         if isinstance(s, six.binary_type):
             s = s.decode(encoding, "replace")
+        # Filter unreadable characters, Python 3 is stricter than python 2 about them.
+        import re
+        s = re.sub(r'[^\x00-\x7f]',r' ',s)
         return old_write(s)
     return impl