Mercurial > public > mercurial-scm > hg
comparison tests/get-with-headers.py @ 36276:c95c8ab2e7ec
tests: fix get-with-headers.py on python3 when writing to stdout
Differential Revision: https://phab.mercurial-scm.org/D2306
author | Augie Fackler <augie@google.com> |
---|---|
date | Sat, 17 Feb 2018 22:39:12 -0500 |
parents | c6ef8e841873 |
children | cfd0c1df5e33 |
comparison
equal
deleted
inserted
replaced
36275:0cacd4df6eb0 | 36276:c95c8ab2e7ec |
---|---|
74 data = response.read() | 74 data = response.read() |
75 | 75 |
76 if args.bodyfile: | 76 if args.bodyfile: |
77 bodyfh = open(args.bodyfile, 'wb') | 77 bodyfh = open(args.bodyfile, 'wb') |
78 else: | 78 else: |
79 bodyfh = sys.stdout | 79 bodyfh = getattr(sys.stdout, 'buffer', sys.stdout) |
80 | 80 |
81 # Pretty print JSON. This also has the beneficial side-effect | 81 # Pretty print JSON. This also has the beneficial side-effect |
82 # of verifying emitted JSON is well-formed. | 82 # of verifying emitted JSON is well-formed. |
83 if formatjson: | 83 if formatjson: |
84 # json.dumps() will print trailing newlines. Eliminate them | 84 # json.dumps() will print trailing newlines. Eliminate them |