diff options
author | Steven Knight <knight@baldmt.com> | 2005-12-01 20:57:48 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2005-12-01 20:57:48 (GMT) |
commit | 6a4fd83b9e9d4533017fa4e1c7233f72b42555c8 (patch) | |
tree | 789ba537fabde1ff80035244575f587e03754215 /src/engine/SCons/Node | |
parent | 3e0e0756b459c354a7f2c16f7157f28ff0d66801 (diff) | |
download | SCons-6a4fd83b9e9d4533017fa4e1c7233f72b42555c8.zip SCons-6a4fd83b9e9d4533017fa4e1c7233f72b42555c8.tar.gz SCons-6a4fd83b9e9d4533017fa4e1c7233f72b42555c8.tar.bz2 |
Handle interpretation of Node.FS objects when wrapped in Proxy instances. (Erling Andersen)
Diffstat (limited to 'src/engine/SCons/Node')
-rw-r--r-- | src/engine/SCons/Node/FS.py | 8 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 14 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 7d4d8df..7f45751 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -993,6 +993,14 @@ class FS(LocalFS): If directory is None, and name is a relative path, then the same applies. """ + if not SCons.Util.is_String(name): + # This handles cases where the object is a Proxy wrapping + # a Node.FS.File object (e.g.). It would be good to handle + # this more directly some day by having the callers of this + # function recognize that a Proxy can be treated like the + # underlying object (that is, get rid of the isinstance() + # calls that explicitly look for a Node.FS.Base object). + name = str(name) if name and name[0] == '#': directory = self.Top name = name[1:] diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index cb98f50..6514375 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -1435,6 +1435,20 @@ class FSTestCase(_tempdirTestCase): failed = failed + 1 assert failed == 0, "%d rel_path() cases failed" % failed + def test_proxy(self): + """Test a Node.FS object wrapped in a proxy instance""" + f1 = self.fs.File('fff') + class Proxy: + # Simplest possibly Proxy class that works for our test, + # this is stripped down from SCons.Util.Proxy. + def __init__(self, subject): + self.__subject = subject + def __getattr__(self, name): + return getattr(self.__subject, name) + p = Proxy(f1) + f2 = self.fs.Entry(p) + assert f1 is f2, (f1, f2) + class DirTestCase(_tempdirTestCase): def test__morph(self): |