logcat = Logcat(android_log_write)
sys.stdout = TextLogStream(
- stdout_prio, "python.stdout", sys.stdout.fileno(),
- errors=sys.stdout.errors)
+ stdout_prio, "python.stdout", sys.stdout.fileno())
sys.stderr = TextLogStream(
- stderr_prio, "python.stderr", sys.stderr.fileno(),
- errors=sys.stderr.errors)
+ stderr_prio, "python.stderr", sys.stderr.fileno())
class TextLogStream(io.TextIOWrapper):
def __init__(self, prio, tag, fileno=None, **kwargs):
+ # The default is surrogateescape for stdout and backslashreplace for
+ # stderr, but in the context of an Android log, readability is more
+ # important than reversibility.
kwargs.setdefault("encoding", "UTF-8")
+ kwargs.setdefault("errors", "backslashreplace")
+
super().__init__(BinaryLogStream(prio, tag, fileno), **kwargs)
self._lock = RLock()
self._pending_bytes = []
self.assertIs(stream.readable(), False)
self.assertEqual(stream.fileno(), fileno)
self.assertEqual("UTF-8", stream.encoding)
+ self.assertEqual("backslashreplace", stream.errors)
self.assertIs(stream.line_buffering, True)
self.assertIs(stream.write_through, False)
- # stderr is backslashreplace by default; stdout is configured
- # that way by libregrtest.main.
- self.assertEqual("backslashreplace", stream.errors)
-
def write(s, lines=None, *, write_len=None):
if write_len is None:
write_len = len(s)