selftest/filter: PY3 Make filter-subunit forgiving of decoding errors
authorNoel Power <noel.power@suse.com>
Fri, 5 Oct 2018 15:49:45 +0000 (16:49 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 23 Oct 2018 03:50:28 +0000 (05:50 +0200)
samba4.local.ndr for one is a test that outputs string in an encoding
that stdin.readline() guesses to be utf8 (but it isn't) filter subunit
can afford to be forgiving of some random text that can't be decoded as
utf8 so lets do that.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/filter-subunit

index d71112296f2a8d74f8f3100b7370f57c2675cf6e..a37b2a5fbdd07ccc0183cd2e3df5d5253e440bdd 100755 (executable)
@@ -102,7 +102,13 @@ else:
                                       flapping=flapping)
 
 try:
-    ret = subunithelper.parse_results(msg_ops, statistics, sys.stdin)
+    from samba.compat import PY3
+    from io import TextIOWrapper as TextIOWrapper
+    if PY3:
+        forgiving_stdin = TextIOWrapper(sys.stdin.buffer, errors='ignore',  encoding='utf-8')
+    else:
+        forgiving_stdin = sys.stdin
+    ret = subunithelper.parse_results(msg_ops, statistics, forgiving_stdin)
 except subunithelper.ImmediateFail:
     sys.stdout.flush()
     sys.exit(1)