diff options
author | Steven Knight <knight@baldmt.com> | 2003-11-09 03:11:32 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-11-09 03:11:32 (GMT) |
commit | b2256bb0f8e1e0f5822d250b58ff123349e58df5 (patch) | |
tree | 0544ff0d91f9cbe5bb1e29c2911c962bcdff8c00 /src/engine/SCons | |
parent | b7308d19648bda8220d69328de74dfcad9a28872 (diff) | |
download | SCons-b2256bb0f8e1e0f5822d250b58ff123349e58df5.zip SCons-b2256bb0f8e1e0f5822d250b58ff123349e58df5.tar.gz SCons-b2256bb0f8e1e0f5822d250b58ff123349e58df5.tar.bz2 |
Don't swallow the AttributeError for an expansion like .bak.
Diffstat (limited to 'src/engine/SCons')
-rw-r--r-- | src/engine/SCons/Node/FS.py | 8 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 26 | ||||
-rw-r--r-- | src/engine/SCons/Sig/MD5.py | 4 | ||||
-rw-r--r-- | src/engine/SCons/Sig/MD5Tests.py | 13 |
4 files changed, 48 insertions, 3 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index cffa2b5..bce5364 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -290,7 +290,13 @@ class EntryProxy(SCons.Util.Proxy): try: return self.dictSpecialAttrs[name](self) except KeyError: - return SCons.Util.Proxy.__getattr__(self, name) + try: + attr = SCons.Util.Proxy.__getattr__(self, name) + except AttributeError: + entry = self.get() + classname = string.split(str(entry.__class__), '.')[-1] + raise AttributeError, "%s instance '%s' has no attribute '%s'" % (classname, entry.name, name) + return attr class Base(SCons.Node.Node): """A generic class for file system entries. This class is for diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 2237959..54c6523 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -1716,6 +1716,32 @@ class SpecialAttrTestCase(unittest.TestCase): assert f.posix.for_signature() == 'baz.blat_posix', \ f.posix.for_signature() + # Check that attempts to access non-existent attributes of the + # subst proxy generate the right exceptions and messages. + caught = None + try: + fs.Dir('ddd').get_subst_proxy().no_such_attr + except AttributeError, e: + assert str(e) == "Dir instance 'ddd' has no attribute 'no_such_attr'", e + caught = 1 + assert caught, "did not catch expected AttributeError" + + caught = None + try: + fs.Entry('eee').get_subst_proxy().no_such_attr + except AttributeError, e: + assert str(e) == "Entry instance 'eee' has no attribute 'no_such_attr'", e + caught = 1 + assert caught, "did not catch expected AttributeError" + + caught = None + try: + fs.File('fff').get_subst_proxy().no_such_attr + except AttributeError, e: + assert str(e) == "File instance 'fff' has no attribute 'no_such_attr'", e + caught = 1 + assert caught, "did not catch expected AttributeError" + fs.BuildDir('foo', 'baz') assert str(f.srcpath) == os.path.normpath('baz/bar/baz.blat'), str(f.srcpath) diff --git a/src/engine/SCons/Sig/MD5.py b/src/engine/SCons/Sig/MD5.py index c50dbb7..21cb24c 100644 --- a/src/engine/SCons/Sig/MD5.py +++ b/src/engine/SCons/Sig/MD5.py @@ -79,10 +79,10 @@ def signature(obj): """Generate a signature for an object """ try: - contents = str(obj.get_contents()) + gc = obj.get_contents except AttributeError: raise AttributeError, "unable to fetch contents of '%s'" % str(obj) - return hexdigest(md5.new(contents).digest()) + return hexdigest(md5.new(str(gc())).digest()) def to_string(signature): """Convert a signature to a string""" diff --git a/src/engine/SCons/Sig/MD5Tests.py b/src/engine/SCons/Sig/MD5Tests.py index 6285e87..67bdfc9 100644 --- a/src/engine/SCons/Sig/MD5Tests.py +++ b/src/engine/SCons/Sig/MD5Tests.py @@ -88,6 +88,19 @@ class MD5TestCase(unittest.TestCase): else: raise AttributeError, "unexpected get_contents() attribute" + # Make sure we don't eat AttributeErrors raised internally + # by the get_contents() method (or anything it calls). + caught = None + try: + class xxx: + def get_contents(self): + raise AttributeError, "internal AttributeError" + signature(xxx()) + except AttributeError, e: + assert str(e) == "internal AttributeError", e + caught = 1 + assert caught, "did not catch expected AttributeError" + def test_to_string(self): assert '698d51a19d8a121ce581499d7b701668' == to_string('698d51a19d8a121ce581499d7b701668') |