Fix binary file signatures on Win32 (Crain).
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 23 Jan 2002 22:15:14 +0000 (22:15 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 23 Jan 2002 22:15:14 +0000 (22:15 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@217 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Node/FS.py
src/engine/SCons/Node/FSTests.py

index 96ce1481e916b21ea1357c2ddca40cbc46741a5c..e21e193b72314b2cb8e3b51158197c90a60c16b8 100644 (file)
@@ -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():
index 1ac5be89f9f8282974d10817490a6cf39f9f419b..dc3c559fcf063dcdc048cf9a0bfb754e216994eb 100644 (file)
@@ -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