summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/engine/SCons/Node/FS.py2
-rw-r--r--src/engine/SCons/Node/FSTests.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 96ce148..e21e193 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -487,7 +487,7 @@ class File(Entry):
def get_contents(self):
if not self.exists():
return ''
- return open(str(self), "r").read()
+ return open(str(self), "rb").read()
def get_timestamp(self):
if self.exists():
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index 1ac5be8..dc3c559 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -414,6 +414,13 @@ class FSTestCase(unittest.TestCase):
f1.build()
assert not f1.cached_exists()
+ # For some reason, in Win32, the \x1a character terminates
+ # the reading of files in text mode. This tests that
+ # get_contents() returns the binary contents.
+ test.write("binary_file", "Foo\x1aBar")
+ f1 = SCons.Node.FS.default_fs.File(test.workpath("binary_file"))
+ assert f1.get_contents() == "Foo\x1aBar", f1.get_contents()
+
#XXX test current() for directories
#XXX test sconsign() for directories