Anonymous committed e8751ef

Handle interpretation of Node.FS objects when wrapped in Proxy instances. (Erling Andersen)

  • Participants
  • Parent commits 53531c6

Comments (0)

Files changed (3)

File src/CHANGES.txt

   - Fix the 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

File src/engine/SCons/Node/

         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:]

File src/engine/SCons/Node/

                 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):