From bd53e768d22c2c0e329bc08b2002ebd1d74ffaa6 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Thu, 7 Mar 2019 17:45:53 +0000 Subject: [PATCH] [testsuite] Drop characters that can't be decoded, restoring parity with Py2. 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lldb/packages/Python/lldbsuite/support/encoded_file.py b/lldb/packages/Python/lldbsuite/support/encoded_file.py index 1b4c7a2e48db..c233e046ba75 100644 --- a/lldb/packages/Python/lldbsuite/support/encoded_file.py +++ b/lldb/packages/Python/lldbsuite/support/encoded_file.py @@ -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