Patchwork D8346: tests: force newlines to LF in tinyproxy.py

login
register
mail settings
Submitter phabricator
Date March 30, 2020, 1:30 a.m.
Message ID <differential-rev-PHID-DREV-p75ue3wh7xcmwiyula5d-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45944/
State New
Headers show

Comments

phabricator - March 30, 2020, 1:30 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Yet another instance where we need to replace the sys.std* streams
  to prevent CRLF from creeping in on Windows.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/tinyproxy.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel
phabricator - April 17, 2020, 6:31 p.m.
marmoute added a comment.
marmoute accepted this revision.


  looks legit

REPOSITORY
  rHG Mercurial

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

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

To: indygreg, #hg-reviewers, marmoute
Cc: marmoute, mercurial-devel
phabricator - April 17, 2020, 6:34 p.m.
marmoute added a comment.
marmoute added a subscriber: mharbison72.
marmoute resigned from this revision.


  actually @mharbison72  comment on D8345 <https://phab.mercurial-scm.org/D8345> make me reconsider. Please allign the status of this with the status of D8345 <https://phab.mercurial-scm.org/D8345>.

REPOSITORY
  rHG Mercurial

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

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

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

Patch

diff --git a/tests/tinyproxy.py b/tests/tinyproxy.py
--- a/tests/tinyproxy.py
+++ b/tests/tinyproxy.py
@@ -14,6 +14,7 @@ 
 
 __version__ = "0.2.1"
 
+import io
 import optparse
 import os
 import select
@@ -25,6 +26,23 @@ 
     util,
 )
 
+# Ensure Windows doesn't emit CRLF.
+if sys.version_info[0] >= 3:
+    sys.stdout = io.TextIOWrapper(
+        sys.stdout.buffer,
+        sys.stdout.encoding,
+        sys.stdout.errors,
+        newline="\n",
+        line_buffering=sys.stdout.line_buffering,
+    )
+    sys.stderr = io.TextIOWrapper(
+        sys.stderr.buffer,
+        sys.stderr.encoding,
+        sys.stderr.errors,
+        newline="\n",
+        line_buffering=sys.stderr.line_buffering,
+    )
+
 httpserver = util.httpserver
 socketserver = util.socketserver
 urlreq = util.urlreq