From 6a4fd83b9e9d4533017fa4e1c7233f72b42555c8 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Thu, 1 Dec 2005 20:57:48 +0000 Subject: Handle interpretation of Node.FS objects when wrapped in Proxy instances. (Erling Andersen) --- src/CHANGES.txt | 5 +++++ src/engine/SCons/Node/FS.py | 8 ++++++++ src/engine/SCons/Node/FSTests.py | 14 ++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 3c3ab20..0833bf8 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -20,6 +20,11 @@ RELEASE 0.97 - XXX - Fix the intelc.py Tool module to not throw an exception if the only installed version is something other than ia32. + From Erling Andersen: + + - Fix interpretation of Node.FS objects wrapped in Proxy instances, + allowing expansion of things like ${File(TARGET)} in command lines. + From Chad Austin: - Allow Help() to be called multiple times, appending to the help 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): -- cgit v0.12