aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStella Stamenova <stilis@microsoft.com>2018-07-20 16:19:36 +0000
committerStella Stamenova <stilis@microsoft.com>2018-07-20 16:19:36 +0000
commit7ba70e88cc0674895e945e1f1a4c9dede82f5c58 (patch)
tree6a80a905254551a34bfe2940d91b862010f0cd89
parent42411242d60a9378f1c2d634c330a033550374e8 (diff)
[llvm-objcopy, tests] Fix several llvm-objcopy tests
Summary: In Python 3, sys.stdout.write expects a string rather than bytes. In order to be able to write the bytes to stdout, we need to use the buffer directly instead. This change is borrowing the implementation for writing to stdout that cat.py uses. Note that we cannot use cat.py directly because the file we are trying to open is a gzip file. Reviewers: asmith, bkramer, alexshap, jakehehrlich Reviewed By: alexshap, jakehehrlich Subscribers: jakehehrlich, llvm-commits Differential Revision: https://reviews.llvm.org/D49515 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337567 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/tools/llvm-objcopy/Inputs/ungzip.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/test/tools/llvm-objcopy/Inputs/ungzip.py b/test/tools/llvm-objcopy/Inputs/ungzip.py
index 41f858edae2..c7b1de96b25 100644
--- a/test/tools/llvm-objcopy/Inputs/ungzip.py
+++ b/test/tools/llvm-objcopy/Inputs/ungzip.py
@@ -2,4 +2,12 @@ import gzip
import sys
with gzip.open(sys.argv[1], 'rb') as f:
- sys.stdout.write(f.read())
+ writer = getattr(sys.stdout, 'buffer', None)
+ if writer is None:
+ writer = sys.stdout
+ if sys.platform == "win32":
+ import os, msvcrt
+ msvcrt.setmode(sys.stdout.fileno(),os.O_BINARY)
+
+ writer.write(f.read())
+ sys.stdout.flush()