Patchwork D6455: testparseutil: stop extracting using std* streams as bytes on py3

login
register
mail settings
Submitter phabricator
Date May 29, 2019, 2:32 p.m.
Message ID <09b3400327383c72c90c54db339b027f@localhost.localdomain>
Download mbox | patch
Permalink /patch/40266/
State Not Applicable
Headers show

Comments

phabricator - May 29, 2019, 2:32 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG37f38e1dea44: testparseutil: stop extracting using std* streams as bytes on py3 (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6455?vs=15285&id=15290

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

AFFECTED FILES
  contrib/testparseutil.py

CHANGE DETAILS




To: durin42, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/contrib/testparseutil.py b/contrib/testparseutil.py
--- a/contrib/testparseutil.py
+++ b/contrib/testparseutil.py
@@ -38,12 +38,6 @@ 
 if ispy3:
     import builtins
 
-    # TODO: .buffer might not exist if std streams were replaced; we'll need
-    # a silly wrapper to make a bytes stream backed by a unicode one.
-    stdin = sys.stdin.buffer
-    stdout = sys.stdout.buffer
-    stderr = sys.stderr.buffer
-
     def bytestr(s):
         # tiny version of pycompat.bytestr
         return s.encode('latin1')
@@ -56,10 +50,6 @@ 
     def opentext(f):
         return open(f, 'r')
 else:
-    stdin = sys.stdin
-    stdout = sys.stdout
-    stderr = sys.stderr
-
     bytestr = str
     sysstr = identity
 
@@ -71,11 +61,11 @@ 
 
 def writeout(data):
     # write "data" in BYTES into stdout
-    stdout.write(data)
+    sys.stdout.write(data)
 
 def writeerr(data):
     # write "data" in BYTES into stderr
-    stderr.write(data)
+    sys.stderr.write(data)
 
 ####################
 
@@ -583,7 +573,7 @@ 
                     if showembedded(f, fp, embeddedfunc, opts):
                         ret = 1
         else:
-            lines = [l for l in stdin.readlines()]
+            lines = [l for l in sys.stdin.readlines()]
             if showembedded('<stdin>', lines, embeddedfunc, opts):
                 ret = 1
         return ret