summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-11-16 02:54:07 (GMT)
committerSteven Knight <knight@baldmt.com>2005-11-16 02:54:07 (GMT)
commitbf2621217e58fd3fca51e19ed4e0af744100f230 (patch)
tree9d9d59abb6a7447c7f5b268fbd703228055f6f4a
parentc32b804b81b2036f9703c1819abc8355409ef2c9 (diff)
downloadSCons-bf2621217e58fd3fca51e19ed4e0af744100f230.zip
SCons-bf2621217e58fd3fca51e19ed4e0af744100f230.tar.gz
SCons-bf2621217e58fd3fca51e19ed4e0af744100f230.tar.bz2
Handle FunctionAction signatures when the function is an object method.
-rw-r--r--src/CHANGES.txt3
-rw-r--r--src/engine/SCons/Action.py29
-rw-r--r--src/engine/SCons/ActionTests.py8
3 files changed, 31 insertions, 9 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index d9d77d1..d75008a 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -381,6 +381,9 @@ RELEASE 0.97 - XXX
- Change the order of the arguments to Configure.Checklib() to match
the documentation.
+ - Handle signature calculation properly when the Python function used
+ for a FunctionAction is an object method.
+
From Chen Lee:
- Handle Visual Studio project and solution files in Unicode.
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index 98de34e..25c7133 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -659,22 +659,33 @@ class FunctionAction(_ActionAction):
So we remove the line number byte codes to prevent
recompilations from moving a Python function.
"""
+ execfunction = self.execfunction
try:
- # "self.execfunction" is a function.
- contents = str(self.execfunction.func_code.co_code)
+ # Test if execfunction is a function.
+ code = execfunction.func_code.co_code
except AttributeError:
- # "self.execfunction" is a callable object.
try:
- contents = str(self.execfunction.__call__.im_func.func_code.co_code)
+ # Test if execfunction is a method.
+ code = execfunction.im_func.func_code.co_code
except AttributeError:
try:
- # See if execfunction will do the heavy lifting for us.
- gc = self.execfunction.get_contents
+ # Test if execfunction is a callable object.
+ code = execfunction.__call__.im_func.func_code.co_code
except AttributeError:
- # This is weird, just do the best we can.
- contents = str(self.execfunction)
+ try:
+ # See if execfunction will do the heavy lifting for us.
+ gc = self.execfunction.get_contents
+ except AttributeError:
+ # This is weird, just do the best we can.
+ contents = str(self.execfunction)
+ else:
+ contents = gc(target, source, env)
else:
- contents = gc(target, source, env)
+ contents = str(code)
+ else:
+ contents = str(code)
+ else:
+ contents = str(code)
contents = remove_set_lineno_codes(contents)
return contents + env.subst(string.join(map(lambda v: '${'+v+'}',
self.varlist)))
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py
index 011cc0d..3cc563b 100644
--- a/src/engine/SCons/ActionTests.py
+++ b/src/engine/SCons/ActionTests.py
@@ -1462,6 +1462,14 @@ class FunctionActionTestCase(unittest.TestCase):
c = a.get_contents(target=[], source=[], env=Environment())
assert c == 'xyzzy', repr(c)
+ class LocalClass:
+ def LocalMethod(self):
+ pass
+ lc = LocalClass()
+ a = SCons.Action.FunctionAction(lc.LocalMethod)
+ c = a.get_contents(target=[], source=[], env=Environment())
+ assert c in matches, repr(c)
+
class ListActionTestCase(unittest.TestCase):
def test___init__(self):