Patchwork D2306: tests: fix get-with-headers.py on python3 when writing to stdout

login
register
mail settings
Submitter phabricator
Date Feb. 18, 2018, 5:36 a.m.
Message ID <differential-rev-PHID-DREV-seond4q6z2fkjgjeu64o-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28044/
State Superseded
Headers show

Comments

phabricator - Feb. 18, 2018, 5:36 a.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/get-with-headers.py

CHANGE DETAILS




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

Patch

diff --git a/tests/get-with-headers.py b/tests/get-with-headers.py
--- a/tests/get-with-headers.py
+++ b/tests/get-with-headers.py
@@ -76,7 +76,7 @@ 
         if args.bodyfile:
             bodyfh = open(args.bodyfile, 'wb')
         else:
-            bodyfh = sys.stdout
+            bodyfh = getattr(sys.stdout, 'buffer', sys.stdout)
 
         # Pretty print JSON. This also has the beneficial side-effect
         # of verifying emitted JSON is well-formed.