From 97226af46815c7789635c7e3aaf9d7fac96473be Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Wed, 23 Jan 2002 22:15:14 +0000 Subject: Fix binary file signatures on Win32 (Crain). --- src/engine/SCons/Node/FS.py | 2 +- src/engine/SCons/Node/FSTests.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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 -- cgit v0.12