From 859f1bbac36edde2b6e2e3099f6af69b4121404c Mon Sep 17 00:00:00 2001 From: stevenknight Date: Wed, 23 Jan 2002 22:15:14 +0000 Subject: [PATCH] Fix binary file signatures on Win32 (Crain). git-svn-id: http://scons.tigris.org/svn/scons/trunk@217 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- 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 96ce1481..e21e193b 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 1ac5be89..dc3c559f 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 -- 2.26.2