summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2017-04-19 15:42:09 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2017-04-19 15:42:09 (GMT)
commit03eb2e5498807786834933b54703b3b9f127e282 (patch)
tree449be58ecb4457544abccc57dc9aa11a6e12489c
parentd624a087a4ed7768052f0ab1c614ea6864179dd5 (diff)
downloadSCons-03eb2e5498807786834933b54703b3b9f127e282.zip
SCons-03eb2e5498807786834933b54703b3b9f127e282.tar.gz
SCons-03eb2e5498807786834933b54703b3b9f127e282.tar.bz2
py2/3 handle differences between py2 and 3 on reading/writing binary data to stdin/stdout
-rw-r--r--test/redirection.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/redirection.py b/test/redirection.py
index ffc76b5..ba35ed0 100644
--- a/test/redirection.py
+++ b/test/redirection.py
@@ -32,11 +32,22 @@ test = TestSCons.TestSCons()
test.write('cat.py', r"""
import sys
+PY3K = sys.version_info >= (3, 0)
+
try:
- input = open(sys.argv[1], 'r').read()
+ input = open(sys.argv[1], 'rb').read()
except IndexError:
- input = sys.stdin.read()
-sys.stdout.write(input)
+ if PY3K:
+ source = sys.stdin.buffer
+ else:
+ source = sys.stdin
+ input = source.read()
+
+if PY3K:
+ sys.stdout.buffer.write(input)
+else:
+ sys.stdout.write(input)
+
sys.exit(0)
""")