diff options
author | Steven Knight <knight@baldmt.com> | 2004-07-08 16:25:24 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-07-08 16:25:24 (GMT) |
commit | 729de7d1d05cf7fa9264573c889ef12e2aceaf6d (patch) | |
tree | 6aaabcf326c1db9d60c1403c98ab7cebaca04bb4 /src | |
parent | b7323556133cd1b757f11411adb53342dcbb1f28 (diff) | |
download | SCons-729de7d1d05cf7fa9264573c889ef12e2aceaf6d.zip SCons-729de7d1d05cf7fa9264573c889ef12e2aceaf6d.tar.gz SCons-729de7d1d05cf7fa9264573c889ef12e2aceaf6d.tar.bz2 |
Fix errors when there are dangling symlinks. (Gary Oberbrunner)
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES.txt | 2 | ||||
-rw-r--r-- | src/engine/SCons/Node/FS.py | 14 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 7 |
3 files changed, 21 insertions, 2 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index f2ee12d..0ecb526 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -157,6 +157,8 @@ RELEASE 0.96 - XXX - Add support for fetching command-line keyword=value arguments in order from an ARGLIST list. + - Avoid stack traces when trying to read dangling symlinks. + From Simon Perkins: - Fix a bug introduced in building shared libraries under MinGW. diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 22d69c0..e61878b 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -494,7 +494,7 @@ class Base(SCons.Node.Node): try: return self._exists except AttributeError: - self._exists = self.fs.exists_or_islink(self.abspath) + self._exists = self.fs.exists(self.abspath) return self._exists def rexists(self): @@ -635,6 +635,8 @@ class Entry(Base): self.__class__ = Dir self._morph() return Dir.get_contents(self) + if self.fs.islink(self.abspath): + return '' # avoid errors for dangling symlinks raise AttributeError def exists(self): @@ -719,9 +721,13 @@ class LocalFS: return os.unlink(path) if hasattr(os, 'symlink'): + def islink(self, path): + return os.path.islink(path) def exists_or_islink(self, path): return os.path.exists(path) or os.path.islink(path) else: + def islink(self, path): + return 0 # no symlinks exists_or_islink = exists #class RemoteFS: @@ -1700,7 +1706,11 @@ class File(Base): else: old = BuildInfo() - mtime = self.get_timestamp() + try: + mtime = self.get_timestamp() + except: + mtime = 0 + raise SCons.Errors.UserError, "no such %s" % self try: if (old.timestamp and old.csig and old.timestamp == mtime): diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index bbc64ef..231d736 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -990,6 +990,13 @@ class FSTestCase(unittest.TestCase): assert c == "", c assert e.__class__ == SCons.Node.FS.Dir + if hasattr(os, 'symlink'): + os.symlink('nonexistent', test.workpath('dangling_symlink')) + e = fs.Entry('dangling_symlink') + c = e.get_contents() + assert e.__class__ == SCons.Node.FS.Entry + assert c == "", c + test.write("tstamp", "tstamp\n") try: # Okay, *this* manipulation accomodates Windows FAT file systems |