[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
This commit is contained in:
Davide Italiano 2019-03-07 17:45:53 +00:00
parent 8a4efd2153
commit bd53e768d2
1 changed files with 3 additions and 0 deletions

View 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