Patchwork tests: apply binary mode to output in seq.py

login
register
mail settings
Submitter Matt Harbison
Date Dec. 2, 2018, 2:47 a.m.
Message ID <857609d4099542c276c8.1543718821@Envy>
Download mbox | patch
Permalink /patch/36898/
State Accepted
Headers show

Comments

Matt Harbison - Dec. 2, 2018, 2:47 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1543718568 18000
#      Sat Dec 01 21:42:48 2018 -0500
# Node ID 857609d4099542c276c84741d4f894f13cde4455
# Parent  104266c4afd3519ddd09e3718590af5062a85b70
tests: apply binary mode to output in seq.py

I noticed this when playing with running tests using WSL, and iterating over the
output yielded '0\r', '1\r',...  Most of the other *.py tools do this, and `seq`
on MSYS lacks '\r' in the output, so this is more consistent.
Yuya Nishihara - Dec. 2, 2018, 11:23 a.m.
On Sat, 01 Dec 2018 21:47:01 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1543718568 18000
> #      Sat Dec 01 21:42:48 2018 -0500
> # Node ID 857609d4099542c276c84741d4f894f13cde4455
> # Parent  104266c4afd3519ddd09e3718590af5062a85b70
> tests: apply binary mode to output in seq.py

Queued, thanks.

Patch

diff --git a/tests/seq.py b/tests/seq.py
--- a/tests/seq.py
+++ b/tests/seq.py
@@ -8,8 +8,17 @@ 
 #   seq START STEP STOP   [START, STOP] stepping by STEP
 
 from __future__ import absolute_import, print_function
+import os
 import sys
 
+try:
+    import msvcrt
+    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
+    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
+    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
+except ImportError:
+    pass
+
 if sys.version_info[0] >= 3:
     xrange = range