tests/hghave.py
changeset 41003 87c98ffbc8c7
parent 40453 1bf3e6041e2c
child 41366 fabb0224a599
--- a/tests/hghave.py	Wed Dec 19 02:57:48 2018 +0100
+++ b/tests/hghave.py	Wed Dec 19 14:51:21 2018 -0500
@@ -16,6 +16,16 @@
     "false": (lambda: False, "nail clipper"),
 }
 
+try:
+    import msvcrt
+    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
+    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
+except ImportError:
+    pass
+
+stdout = getattr(sys.stdout, 'buffer', sys.stdout)
+stderr = getattr(sys.stderr, 'buffer', sys.stderr)
+
 if sys.version_info[0] >= 3:
     def _bytespath(p):
         if p is None:
@@ -90,11 +100,12 @@
     result = checkfeatures(features)
 
     for missing in result['missing']:
-        sys.stderr.write('skipped: unknown feature: %s\n' % missing)
+        stderr.write(('skipped: unknown feature: %s\n'
+                      % missing).encode('utf-8'))
     for msg in result['skipped']:
-        sys.stderr.write('skipped: %s\n' % msg)
+        stderr.write(('skipped: %s\n' % msg).encode('utf-8'))
     for msg in result['error']:
-        sys.stderr.write('%s\n' % msg)
+        stderr.write(('%s\n' % msg).encode('utf-8'))
 
     if result['missing']:
         sys.exit(2)