summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Action.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Action.py')
-rw-r--r--src/engine/SCons/Action.py53
1 files changed, 30 insertions, 23 deletions
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index c24d0be..cfd4a50 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -946,31 +946,38 @@ class FunctionAction(_ActionAction):
return "%s(target, source, env)" % name
def execute(self, target, source, env):
- rsources = map(rfile, source)
+ exc_info = (None,None,None)
try:
- result = self.execfunction(target=target, source=rsources, env=env)
- except EnvironmentError, e:
- # If an IOError/OSError happens, raise a BuildError.
- # Report the name of the file or directory that caused the
- # error, which might be different from the target being built
- # (for example, failure to create the directory in which the
- # target file will appear).
- try: filename = e.filename
- except AttributeError: filename = None
- result = SCons.Errors.BuildError(node=target,
- errstr=e.strerror,
- status=1,
- filename=filename,
- action=self,
- command=self.strfunction(target, source, env))
- else:
+ rsources = map(rfile, source)
+ try:
+ result = self.execfunction(target=target, source=rsources, env=env)
+ except Exception, e:
+ result = e
+ exc_info = sys.exc_info()
+
if result:
- msg = "Error %s" % result
- result = SCons.Errors.BuildError(errstr=msg,
- status=result,
- action=self,
- command=self.strfunction(target, source, env))
- return result
+ result = SCons.Errors.convert_to_BuildError(result, exc_info)
+ result.node=target
+ result.action=self
+ result.command=self.strfunction(target, source, env)
+
+ # FIXME: This maintains backward compatibility with respect to
+ # which type of exceptions were returned by raising an
+ # exception and which ones were returned by value. It would
+ # probably be best to always return them by value here, but
+ # some codes do not check the return value of Actions and I do
+ # not have the time to modify them at this point.
+ if (exc_info[1] and
+ not isinstance(exc_info[1],EnvironmentError)):
+ raise result
+
+ return result
+ finally:
+ # Break the cycle between the traceback object and this
+ # function stack frame. See the sys.exc_info() doc info for
+ # more information about this issue.
+ del exc_info
+
def get_presig(self, target, source, env):
"""Return the signature contents of this callable action."""