From 3e8273f2f0d666c8f3de0987ea9f0cf9b7a04a79 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Thu, 1 Dec 2005 20:57:48 +0000 Subject: [PATCH] Handle interpretation of Node.FS objects when wrapped in Proxy instances. (Erling Andersen) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1400 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- 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 3c3ab20f..0833bf85 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 7d4d8dfe..7f45751e 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 cb98f506..65143759 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): -- 2.26.2