Patchwork D8341: tests: force \n newlines when writing to sys.stdout

login
register
mail settings
Submitter phabricator
Date April 1, 2020, 7:09 p.m.
Message ID <b11b9fa4b94eec34f0877f1c85c84c90@localhost.localdomain>
Download mbox | patch
Permalink /patch/45980/
State Not Applicable
Headers show

Comments

phabricator - April 1, 2020, 7:09 p.m.
Closed by commit rHGd359f0d1a3d3: tests: force \n newlines when writing to sys.stdout (authored by indygreg).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8341?vs=20914&id=20951

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8341/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8341

AFFECTED FILES
  tests/filtertraceback.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/filtertraceback.py b/tests/filtertraceback.py
--- a/tests/filtertraceback.py
+++ b/tests/filtertraceback.py
@@ -4,8 +4,19 @@ 
 
 from __future__ import absolute_import, print_function
 
+import io
 import sys
 
+if sys.version_info[0] >= 3:
+    # Prevent \r from being inserted on Windows.
+    sys.stdout = io.TextIOWrapper(
+        sys.stdout.buffer,
+        sys.stdout.encoding,
+        sys.stdout.errors,
+        newline="\n",
+        line_buffering=sys.stdout.line_buffering,
+    )
+
 state = 'none'
 
 for line in sys.stdin: